Documentation
¶
Overview ¶
Package javanum ports the JDK's floating-point text parsers, Double.parseDouble and Float.parseFloat (FloatingDecimal .readJavaFormatString), which Java's record layer uses for CAST(string AS DOUBLE/FLOAT) and for index options. Go's strconv grammar differs (it accepts "inf", "nan" and digit underscores and refuses signs on NaN, the f/F/d/D suffixes and out-of-range magnitudes), and its NaN is not Java's.
Index ¶
Constants ¶
const ( NaN64Bits uint64 = 0x7ff8000000000000 NaN32Bits uint32 = 0x7fc00000 )
NaN64Bits and NaN32Bits are Double.NaN and Float.NaN, the one NaN each parser returns: Go's math.NaN() is 0x7ff8000000000001, which packs to a different index key and record byte than the NaN Java writes.
Variables ¶
This section is empty.
Functions ¶
func ParseDouble ¶
ParseDouble is Double.parseDouble: the value trimmed of characters at or below U+0020, then an optional sign and "NaN" or "Infinity", or a hexadecimal significand with its required binary exponent ("0x1.8p1"), or ASCII decimal digits with an optional point (at least one digit) and exponent, each optionally ended by one of f, F, d or D. A magnitude too large is an infinity and one too small a zero; every NaN is Double.NaN.
func ParseFloat ¶
ParseFloat is Float.parseFloat: ParseDouble's grammar, the value rounded once, directly to binary32 (never through a double, which can round twice); every NaN is Float.NaN.
Types ¶
type FormatError ¶
type FormatError struct {
// Input is the refused text, trimmed as the parser trims it.
Input string
// Text, when set, is the exception's own message instead of
// forInputString's: "empty String" for a value that trims to nothing and
// "multiple points" for a second point in the significand.
Text string
}
FormatError is Java's NumberFormatException from the parsers.
func (*FormatError) Error ¶
func (e *FormatError) Error() string
Error is the exception's getMessage().
type IllegalArgumentError ¶
type IllegalArgumentError struct {
Message string
}
IllegalArgumentError is Java's IllegalArgumentException. It lives here, below both the record layer and the R-tree, so either can raise it and errors.As matches one type.
func (*IllegalArgumentError) Error ¶
func (e *IllegalArgumentError) Error() string
type IllegalStateError ¶
type IllegalStateError struct {
Message string
}
IllegalStateError is Java's IllegalStateException. It lives here, below both the record layer and the R-tree, so either can raise it and errors.As matches one type.
func (*IllegalStateError) Error ¶
func (e *IllegalStateError) Error() string