Documentation
¶
Index ¶
- func Float64(value any) (float64, error)
- func Int64Exact(value any) (int64, bool)
- func OptionalFloat64FromPointer[T NumericScalar](value *T) (parsed float64, omitted bool, err error)
- func OptionalPointerValue[T any](value *T) (T, bool)
- func ToFloat64(value any) (float64, bool)
- func TryParseNumber(s string) any
- type NumericScalar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Int64Exact ¶
Int64Exact extracts an exact int64 from value without a float64 hop. It reports ok=false when the value is not integral, overflows int64, or has a type it cannot losslessly interpret; callers then fall back to the float64 path (which keeps today's semantics).
func OptionalFloat64FromPointer ¶
func OptionalFloat64FromPointer[T NumericScalar](value *T) (parsed float64, omitted bool, err error)
OptionalFloat64FromPointer converts an optional numeric pointer to float64; a nil pointer reports omitted=true.
func OptionalPointerValue ¶
OptionalPointerValue dereferences an optional pointer; a nil pointer reports omitted=true with the zero value.
func TryParseNumber ¶
TryParseNumber parses s as int64, then float64, falling back to the raw string. Integral spellings in decimal or exponent form ("42.0", "9.007199254740993e15", "1.5e3"), and the hex-float and underscore forms ParseFloat also accepts ("0x1p4", "1_000"), refine to exact int64 when they fit (#357). ParseFloat is the sole acceptance authority — the refinement runs only on strings it already accepted, so the grammar neither widens (rational syntax like "1/3" stays a raw string) nor narrows. Integral values beyond int64 range and genuinely fractional literals — including nonzero literals that underflow float64 to zero — stay float64.