com.fasterxml.jackson.jr.private_.io.doubleparser.FloatBitsFromCharArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-jr-all Show documentation
Show all versions of jackson-jr-all Show documentation
"Uber" jar that contains all Jackson jr components as well as underlying Jackson core
Streaming, in a single jar.
/**
* References:
*
* - This class has been derived from "FastDoubleParser".
* - Copyright (c) Werner Randelshofer. Apache 2.0 License.
* github.com.
*
*/
package com.fasterxml.jackson.core.io.doubleparser;
/**
* Parses a {@code float} from a {@code char} array.
*/
class FloatBitsFromCharArray extends AbstractFloatingPointBitsFromCharArray {
/**
* Creates a new instance.
*/
public FloatBitsFromCharArray() {
}
@Override
long nan() {
return Float.floatToRawIntBits(Float.NaN);
}
@Override
long negativeInfinity() {
return Float.floatToRawIntBits(Float.NEGATIVE_INFINITY);
}
@Override
long positiveInfinity() {
return Float.floatToRawIntBits(Float.POSITIVE_INFINITY);
}
@Override
long valueOfFloatLiteral(char[] str, int startIndex, int endIndex, boolean isNegative,
long significand, int exponent, boolean isSignificandTruncated,
int exponentOfTruncatedSignificand) {
float result = FastFloatMath.decFloatLiteralToFloat(isNegative, significand, exponent, isSignificandTruncated, exponentOfTruncatedSignificand);
return Float.isNaN(result) ? (long) Float.floatToRawIntBits(Float.parseFloat(new String(str, startIndex, endIndex - startIndex))) : Float.floatToRawIntBits(result);
}
@Override
long valueOfHexLiteral(
char[] str, int startIndex, int endIndex, boolean isNegative, long significand, int exponent,
boolean isSignificandTruncated, int exponentOfTruncatedSignificand) {
float d = FastFloatMath.hexFloatLiteralToFloat(isNegative, significand, exponent, isSignificandTruncated, exponentOfTruncatedSignificand);
return Float.floatToRawIntBits(Float.isNaN(d) ? Float.parseFloat(new String(str, startIndex, endIndex - startIndex)) : d);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy