Top Description Fields Constructors Methods
ch.randelshofer.fastdoubleparser

pack-priv abstract Class AbstractJsonFloatingPointBitsFromCharArray

extends AbstractFloatValueParser
Class Inheritance
Known Direct Subclasses
ch.randelshofer.fastdoubleparser.JsonDoubleBitsFromCharArray

Parses a Java FloatingPointLiteral from a char array.

This class should have a type parameter for the return value of its parse methods. Unfortunately Java does not support type parameters for primitive types. As a workaround we use long. A long has enough bits to fit a double value or a float value.

See JavaDoubleParser for the grammar of FloatingPointLiteral.

Field Summary

Inherited from ch.randelshofer.fastdoubleparser.AbstractFloatValueParser:
MAX_EXPONENT_NUMBERMAX_INPUT_LENGTHMINIMAL_NINETEEN_DIGIT_INTEGER

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final long

Returns:

the bit pattern of the parsed value, if the input is legal; otherwise, -1L.
parseNumber
(char[]
a string containing a FloatingPointLiteralWithWhiteSpace
str
,
int
start offset of FloatingPointLiteralWithWhiteSpace in str
offset
,
int
length of FloatingPointLiteralWithWhiteSpace in str
length
)

Parses a number production.

private int
tryToParseEightDigits(char[] str, int offset)

pack-priv abstract long

Returns:

the bit pattern of the parsed value, if the input is legal; otherwise, -1L.
valueOfFloatLiteral
(char[]
the string that contains the float literal (and maybe more)
str
,
int
the start index (inclusive) of the float literal inside the string
startIndex
,
int
the end index (exclusive) of the float literal inside the string
endIndex
,
boolean
whether the float value is negative
isNegative
,
long
the significand of the float value (can be truncated)
significand
,
int
the exponent of the float value
exponent
,
boolean
whether the significand is truncated
isSignificandTruncated
,
int
the exponent value of the truncated significand
exponentOfTruncatedSignificand
)

Computes a float value from the given components of a decimal float literal.

Constructor Detail

AbstractJsonFloatingPointBitsFromCharArrayback to summary
pack-priv AbstractJsonFloatingPointBitsFromCharArray()

Method Detail

parseNumberback to summary
public final long parseNumber(char[] str, int offset, int length)

Parses a number production.

See JsonDoubleParser for the grammar of number.

Parameters
str:char[]

a string containing a FloatingPointLiteralWithWhiteSpace

offset:int

start offset of FloatingPointLiteralWithWhiteSpace in str

length:int

length of FloatingPointLiteralWithWhiteSpace in str

Returns:long

the bit pattern of the parsed value, if the input is legal; otherwise, -1L.

tryToParseEightDigitsback to summary
private int tryToParseEightDigits(char[] str, int offset)
valueOfFloatLiteralback to summary
pack-priv abstract long valueOfFloatLiteral(char[] str, int startIndex, int endIndex, boolean isNegative, long significand, int exponent, boolean isSignificandTruncated, int exponentOfTruncatedSignificand)

Computes a float value from the given components of a decimal float literal.

Parameters
str:char[]

the string that contains the float literal (and maybe more)

startIndex:int

the start index (inclusive) of the float literal inside the string

endIndex:int

the end index (exclusive) of the float literal inside the string

isNegative:boolean

whether the float value is negative

significand:long

the significand of the float value (can be truncated)

exponent:int

the exponent of the float value

isSignificandTruncated:boolean

whether the significand is truncated

exponentOfTruncatedSignificand:int

the exponent value of the truncated significand

Returns:long

the bit pattern of the parsed value, if the input is legal; otherwise, -1L.