public final class NumberUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static interface |
NumberUtils.LongBiFunction |
| Modifier and Type | Field and Description |
|---|---|
(package private) static long |
INFI |
(package private) static long |
INFINITY |
(package private) static int |
MOD_DOUBLE_EXP |
(package private) static long |
MOD_DOUBLE_MANTISSA |
(package private) static int |
MOD_FLOAT_EXP |
(package private) static int |
MOD_FLOAT_MANTISSA |
(package private) static NumberUtils.LongBiFunction |
MULTIPLY_HIGH |
(package private) static double[] |
NEGATIVE_DECIMAL_POWER |
(package private) static char[][] |
NEGATIVE_DECIMAL_POWER_CHARS |
(package private) static long |
NITY |
(package private) static double[] |
POSITIVE_DECIMAL_POWER |
(package private) static char[][] |
POSITIVE_DECIMAL_POWER_CHARS |
(package private) static long[] |
POW10_LONG_VALUES |
(package private) static java.math.BigInteger[] |
POW5_BI_VALUES |
(package private) static long[] |
POW5_LONG_VALUES |
(package private) static short[] |
TWO_DIGITS_16_BITS |
(package private) static int[] |
TWO_DIGITS_32_BITS |
| Modifier | Constructor and Description |
|---|---|
private |
NumberUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Scientific |
doubleToScientific(double doubleValue)
Conversion of ieee floating point numbers to Scientific notation
|
static Scientific |
floatToScientific(float floatValue) |
(package private) static long |
multiplyHigh(long x,
long y) |
(package private) static long |
multiplyHighAndShift(long x,
long y,
int shift)
multiplyOutput
|
(package private) static long |
multiplyHighAndShift(long x,
long y,
long y32,
int s)
Unsigned algorithm: (H * 2^64 * 2^n + L * 2^n + H1 * 2^64 + L1) / 2^(n+s) = (H * 2^64 + L + (H1 * 2^64 + L1) / 2^n) / 2^s
|
private static int |
writeDecimal(long value,
int digitCnt,
int e10,
byte[] buf,
int off) |
private static int |
writeDecimal(long value,
int digitCnt,
int e10,
char[] buf,
int off) |
static int |
writeDouble(byte[] buf,
int off,
double doubleValue,
boolean json,
boolean writeSpecialAsString) |
static int |
writeDouble(char[] buf,
int off,
double doubleValue,
boolean json,
boolean writeSpecialAsString) |
static int |
writeFloat(byte[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString) |
static int |
writeFloat(char[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString) |
private static int |
writeSpecial(byte[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString) |
private static int |
writeSpecial(char[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString) |
static final NumberUtils.LongBiFunction MULTIPLY_HIGH
static final long INFI
static final long NITY
static final long INFINITY
static final double[] POSITIVE_DECIMAL_POWER
static final double[] NEGATIVE_DECIMAL_POWER
static final long[] POW10_LONG_VALUES
static final long[] POW5_LONG_VALUES
static final java.math.BigInteger[] POW5_BI_VALUES
static final int MOD_DOUBLE_EXP
static final long MOD_DOUBLE_MANTISSA
static final char[][] POSITIVE_DECIMAL_POWER_CHARS
static final char[][] NEGATIVE_DECIMAL_POWER_CHARS
static final int MOD_FLOAT_EXP
static final int MOD_FLOAT_MANTISSA
static final int[] TWO_DIGITS_32_BITS
static final short[] TWO_DIGITS_16_BITS
static long multiplyHigh(long x,
long y)
static long multiplyHighAndShift(long x,
long y,
int shift)
x - > 0y - > 0shift - > 0static long multiplyHighAndShift(long x,
long y,
long y32,
int s)
use BigInteger: BigInteger.valueOf(pd.y).shiftLeft(n).add(BigInteger.valueOf(f & MASK_32_BITS)).multiply(BigInteger.valueOf(x)).shiftRight(s + n).longValue()
x - 63bitsy - 63bitsy32 - unsigned int32 f(32bits)s - s > 0public static Scientific doubleToScientific(double doubleValue)
Using the difference estimation method
The output may not be the shortest, but the general result is correct
doubleValue - > 0public static int writeDouble(byte[] buf,
int off,
double doubleValue,
boolean json,
boolean writeSpecialAsString)
public static int writeDouble(char[] buf,
int off,
double doubleValue,
boolean json,
boolean writeSpecialAsString)
public static int writeFloat(byte[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString)
public static int writeFloat(char[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString)
private static int writeSpecial(byte[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString)
private static int writeSpecial(char[] buf,
int off,
float floatValue,
boolean json,
boolean writeSpecialAsString)
public static Scientific floatToScientific(float floatValue)
private static int writeDecimal(long value,
int digitCnt,
int e10,
byte[] buf,
int off)
private static int writeDecimal(long value,
int digitCnt,
int e10,
char[] buf,
int off)