← Standard library

FloatParse

static class FloatParse
import FloatParse from Wax;

Low-level decimal-to-IEEE parser and its arithmetic helpers. ParseFloat/ParseDouble return bits, outcome, and consumed byte position without throwing. Prefer float.Parse/double.Parse or ParseDetailed for normal application code. Other helpers operate on parser-specific intermediate representations and require the matching kind selector and table bounds.

FloatParse.wax:882

Inherits from object. Follow these links for inherited members.

Members

Umul128method

public static fn Umul128(uint64 a, uint64 b) : FpU128

Returns the complete unsigned 64-by-64-bit product as low/high halves.

FloatParse.wax:891

CountLeadingZeros64method

public static fn CountLeadingZeros64(uint64 x) : uint32

Counts leading zero bits; zero returns 64.

FloatParse.wax:911

B10ToB2method

public static fn B10ToB2(int32 q) : int32

Computes the parser's fixed-point binary exponent estimate from a decimal exponent. Use only within the parser's bounded decimal exponent range.

FloatParse.wax:932

kKindFloatconst

const int32 kKindFloat = 0

Selects binary32 arithmetic in the low-level conversion helpers.

FloatParse.wax:942

kKindDoubleconst

const int32 kKindDouble = 1

Selects binary64 arithmetic in the low-level conversion helpers.

FloatParse.wax:946

kOutcomeOkconst

const int32 kOutcomeOk = 0

Successful parsing or conversion (zero).

FloatParse.wax:952

kOutcomeInvalidInputconst

const int32 kOutcomeInvalidInput = 1

Invalid numeric input (one).

FloatParse.wax:956

kOutcomeOutOfRangeconst

const int32 kOutcomeOutOfRange = 2

A converted value outside the accepted representable range (two).

FloatParse.wax:960

ComputeProductApproximationmethod

public static fn ComputeProductApproximation(int64 q, uint64 w, int32 vk) : FpU128

Computes a guarded cached-power product for decimal conversion. q must lie in the cached double power-of-ten range; vk selects float or double precision.

FloatParse.wax:974

ComputeFloatmethod

public static fn ComputeFloat(int64 q, uint64 w, int32 vk) : AdjustedMantissa

Attempts conversion of w*10^q to rounded IEEE mantissa/exponent fields for vk. A negative power2 signals that the caller must use the digit-comparison slow path.

FloatParse.wax:999

ComputeErrormethod

public static fn ComputeError(int64 q, uint64 w, int32 vk) : AdjustedMantissa

Builds the error-path mantissa/exponent intermediate used before digit comparison. Requires a nonzero decimal significand and a supported cached-power exponent.

FloatParse.wax:1094

ClingerFastPathDoublemethod

public static fn ClingerFastPathDouble(uint64 mantissa, int64 exponent, bool negative) : ClingerResult

Attempts exact fast-path binary64 conversion of a decimal significand and exponent. Check ok before reading bits64.

FloatParse.wax:1108

ClingerFastPathFloatmethod

public static fn ClingerFastPathFloat(uint64 mantissa, int64 exponent, bool negative) : ClingerResult

Attempts exact fast-path binary32 conversion of a decimal significand and exponent. Check ok before reading bits32.

FloatParse.wax:1133

ParseInfnanmethod

public static fn ParseInfnan(ReadOnlySpan<uint8> s, uint64 fmt) : InfnanResult

Recognizes case-insensitive inf/infinity/nan prefixes in a nonempty byte span. A minus is allowed; a plus requires AllowLeadingPlus. The caller enforces NoInfnan and whitespace policy. Check ok and lastMatch; trailing bytes can remain.

FloatParse.wax:1171

AmToFloatDoublemethod

public static fn AmToFloatDouble(bool negative, AdjustedMantissa am) : uint64

Packs a successfully rounded mantissa/exponent and sign into binary64 bits. Requires IEEE packing fields, not an extended or failed intermediate.

FloatParse.wax:1224

AmToFloatFloatmethod

public static fn AmToFloatFloat(bool negative, AdjustedMantissa am) : uint32

Packs a successfully rounded mantissa/exponent and sign into binary32 bits. Requires IEEE packing fields, not an extended or failed intermediate.

FloatParse.wax:1237

IsOutOfRangemethod

public static fn IsOutOfRange(uint64 originalMantissa, AdjustedMantissa am, int32 vk) : bool

Checks whether a nonzero decimal input rounded to zero or infinity for vk. Expects a rounded conversion result.

FloatParse.wax:1251

MakeAdjustedMantissamethod

public static fn MakeAdjustedMantissa(uint64 mantissa, int32 power2) : AdjustedMantissa

Creates a mantissa/exponent record without validation.

FloatParse.wax:1262

MakeOptionsmethod

public static fn MakeOptions(uint64 fmt, uint8 dp) : FloatParseOptions

Creates explicit format-bit and one-byte decimal-point options, like FloatParseOptions.Custom.

FloatParse.wax:1271

ParseNumberStringmethod

public static fn ParseNumberString(ReadOnlySpan<uint8> s, FloatParseOptions options, bool jsonFmt) : ParsedNumber

Scans a numeric prefix from a nonempty span. Returned ranges are relative to that span; jsonFmt must agree with the selected JSON grammar. Check valid before consuming the significand.

FloatParse.wax:1305

ParseMantissamethod

public static fn ParseMantissa(ReadOnlySpan<uint8> s, ParsedNumber num, int32 maxDigits) : ParseMantissaResult

Collects significant digits from the original span using ranges in a valid ParsedNumber. Use the matching parser limit: 769 digits for double or 114 for float.

FloatParse.wax:1573

ScientificExponentmethod

public static fn ScientificExponent(uint64 mantissa, int32 exponent) : int32

Adds the number of decimal significand digits minus one to exponent. A zero mantissa leaves exponent unchanged.

FloatParse.wax:1670

ToExtendedDoublemethod

public static fn ToExtendedDouble(uint64 bits) : AdjustedMantissa

Extracts an unsigned extended significand and binary exponent from finite binary64 bits. Sign is handled separately.

FloatParse.wax:1692

ToExtendedFloatmethod

public static fn ToExtendedFloat(uint32 bits) : AdjustedMantissa

Extracts an unsigned extended significand and binary exponent from finite binary32 bits. Sign is handled separately.

FloatParse.wax:1714

ToExtendedHalfwayDoublemethod

public static fn ToExtendedHalfwayDouble(uint64 bits) : AdjustedMantissa

Builds the extended halfway value above the finite positive binary64 value, for rounding comparisons.

FloatParse.wax:1736

ToExtendedHalfwayFloatmethod

public static fn ToExtendedHalfwayFloat(uint32 bits) : AdjustedMantissa

Builds the extended halfway value above the finite positive binary32 value, for rounding comparisons.

FloatParse.wax:1750

RoundDownmethod

public static fn RoundDown(AdjustedMantissa am, int32 vk) : AdjustedMantissa

Rounds the parser's scaled intermediate downward to IEEE mantissa/exponent fields for vk.

FloatParse.wax:1779

RoundTieEvenTruncatedmethod

public static fn RoundTieEvenTruncated(AdjustedMantissa am, bool truncated, int32 vk) : AdjustedMantissa

Rounds a scaled intermediate to nearest, ties to even, using truncated to account for discarded nonzero digits.

FloatParse.wax:1810

RoundTieEvenCmpmethod

public static fn RoundTieEvenCmp(AdjustedMantissa am, int32 ord, int32 vk) : AdjustedMantissa

Rounds a scaled intermediate to nearest, ties to even, using the comparison ordering against the exact halfway value.

FloatParse.wax:1862

DigitCompmethod

public static fn DigitComp(ReadOnlySpan<uint8> s, ParsedNumber num, AdjustedMantissa am, int32 vk) : AdjustedMantissa

Resolves an uncertain conversion by comparing decimal digits against the binary boundary. Pass the original span, its valid ParsedNumber, and matching intermediate/kind.

FloatParse.wax:1957

ParseDoublemethod

public static fn ParseDouble(ReadOnlySpan<uint8> s, FloatParseOptions options) : DoubleResult

Parses a binary64 numeric prefix without throwing. Returns bits, outcome, and a byte position. Success can leave trailing bytes; require outcome == kOutcomeOk and position == s.length for whole-span consumption.

FloatParse.wax:1979

ParseFloatmethod

public static fn ParseFloat(ReadOnlySpan<uint8> s, FloatParseOptions options) : FloatResult

Parses a binary32 numeric prefix without throwing. Returns bits, outcome, and a byte position. Success can leave trailing bytes; require outcome == kOutcomeOk and position == s.length for whole-span consumption.

FloatParse.wax:2057