format_canonical_float
Stable function · Document I/O
Tier: stable · Kind: function · Topic: Document I/O
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
format_canonical_float | formatCanonicalFloat | not exported | format_canonical_float | not exported |
Julia
format_canonical_float(f::Float64)
format_canonical_float(f::Float64) -> String
Format a finite Float64 per RFC §5.4.6.
TypeScript
function formatCanonicalFloat(f: number): string
Format a finite number as a byte-CANONICAL float token per RFC §5.4.6.
Only handles float-typed values: integer-typed NumericLiteral nodes are
emitted as bare JSON integers by canonicalJson
directly.
NAMING: distinct from formatFloatToken in ./numeric-literal (the
document-serialization emitter used by toJson() / losslessJsonStringify).
This canonical version additionally NORMALIZES exponent notation — it strips
the leading + (RFC §5.4.6: “no leading + on the exponent”) so 1e25 emits
as 1e25, not 1e+25, and forces the §5.4.6 exponent thresholds. Use this
one for canonical output, formatFloatToken for wire round-trip.
Python
Python does not export this function.
Rust
pub fn format_canonical_float(f: f64) -> String
Format a finite f64 per RFC §5.4.6.
Go
Go does not export this function.