Top Description Fields Constructors Methods
com.fasterxml.jackson.core.io.schubfach

pack-priv final Class MathUtils

extends Object
Class Inheritance

This class exposes package private utilities for other classes. Thus, all methods are assumed to be invoked with correct arguments, so these are not checked at all.
Author
Raffaello Giulietti

Field Summary

Modifier and TypeField and Description
private static final long
private static final long
private static final long
private static final long[]
g

pack-priv static final int
H

pack-priv static final int
pack-priv static final int
private static final long[]
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static int

Returns:

⌊log102e⌋.
flog10pow2
(int
The exponent of 2, which should meet |e| ≤ 5_456_721 for safe results.
e
)

Returns the unique integer k such that 10k ≤ 2e < 10k+1.

pack-priv static int

Returns:

⌊log10(3/4 · 2e)⌋.
flog10threeQuartersPow2
(int
The exponent of 2, which should meet -2_956_395 ≤ e ≤ 2_500_325 for safe results.
e
)

Returns the unique integer k such that 10k ≤ 3/4 · 2e < 10k+1.

pack-priv static int

Returns:

⌊log210e⌋.
flog2pow10
(int
The exponent of 10, which should meet |e| ≤ 1_838_394 for safe results.
e
)

Returns the unique integer k such that 2k ≤ 10e < 2k+1.

pack-priv static long

Returns:

g0 as described in g1(int).
g0
(int
The exponent of 10, which must meet K_MIN ≤ e ≤ K_MAX.
k
)

Returns g0 as described in g1(int).

pack-priv static long

Returns:

g1 as described above.
g1
(int
The exponent of 10, which must meet K_MIN ≤ e ≤ K_MAX.
k
)

Let 10-k = β 2r, for the unique pair of integer r and real β meeting 2125 ≤ β < 2126.

pack-priv static long
multiplyHigh(long x, long y)

pack-priv static long

Returns:

10e.
pow10
(int
The exponent which must meet 0 ≤ e ≤ H.
e
)

Returns 10e.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

A_10back to summary
private static final long A_10
C_10back to summary
private static final long C_10
C_2back to summary
private static final long C_2
gback to summary
private static final long[] g
Hback to summary
pack-priv static final int H
K_MAXback to summary
pack-priv static final int K_MAX
K_MINback to summary
pack-priv static final int K_MIN
pow10back to summary
private static final long[] pow10
Q_10back to summary
private static final int Q_10
Q_2back to summary
private static final int Q_2

Constructor Detail

MathUtilsback to summary
private MathUtils()

Method Detail

flog10pow2back to summary
pack-priv static int flog10pow2(int e)

Returns the unique integer k such that 10k ≤ 2e < 10k+1.

The result is correct when |e| ≤ 5_456_721. Otherwise the result is undefined.

Parameters
e:int

The exponent of 2, which should meet |e| ≤ 5_456_721 for safe results.

Returns:int

⌊log102e⌋.

flog10threeQuartersPow2back to summary
pack-priv static int flog10threeQuartersPow2(int e)

Returns the unique integer k such that 10k ≤ 3/4 · 2e < 10k+1.

The result is correct when -2_956_395 ≤ e ≤ 2_500_325. Otherwise the result is undefined.

Parameters
e:int

The exponent of 2, which should meet -2_956_395 ≤ e ≤ 2_500_325 for safe results.

Returns:int

⌊log10(3/4 · 2e)⌋.

flog2pow10back to summary
pack-priv static int flog2pow10(int e)

Returns the unique integer k such that 2k ≤ 10e < 2k+1.

The result is correct when |e| ≤ 1_838_394. Otherwise the result is undefined.

Parameters
e:int

The exponent of 10, which should meet |e| ≤ 1_838_394 for safe results.

Returns:int

⌊log210e⌋.

g0back to summary
pack-priv static long g0(int k)

Returns g0 as described in g1(int).

Parameters
k:int

The exponent of 10, which must meet K_MIN ≤ e ≤ K_MAX.

Returns:long

g0 as described in g1(int).

g1back to summary
pack-priv static long g1(int k)

Let 10-k = β 2r, for the unique pair of integer r and real β meeting 2125 ≤ β < 2126. Further, let g = ⌊β⌋ + 1. Split g into the higher 63 bits g1 and the lower 63 bits g0. Thus, g1 = ⌊g 2-63⌋ and g0 = g - g1 263.

This method returns g1 while g0(int) returns g0.

If needed, the exponent r can be computed as r = flog2pow10(-k) - 125 (see flog2pow10(int)).

Parameters
k:int

The exponent of 10, which must meet K_MIN ≤ e ≤ K_MAX.

Returns:long

g1 as described above.

multiplyHighback to summary
pack-priv static long multiplyHigh(long x, long y)
pow10back to summary
pack-priv static long pow10(int e)

Returns 10e.

Parameters
e:int

The exponent which must meet 0 ≤ e ≤ H.

Returns:long

10e.