Skip to content

Float formatting loses original representation #376

Description

@gildor

Summary

ktoml parses all TOML floats into Double, which loses the original text representation. Scientific notation 5e+22 may become 50000000000000000000000.0 after round-trip. While the value is preserved, the representation is not.

This is analogous to how ktoml already tracks IntegerRepresentation (DECIMAL, HEX, OCTAL, BINARY) for TomlLong — but no such tracking exists for floats.

Affected toml-test cases (2)

Found via toml-lang/toml-test compliance suite:

  • valid/float/exponent.toml — scientific notation values
  • valid/spec-1.0.0/float-0.toml — mix of decimal and scientific

Suggested fix

Add a FloatRepresentation enum (DECIMAL, SCIENTIFIC) similar to IntegerRepresentation, and store it in TomlDouble. The writer uses it to choose the output format.

Related: #32, #373

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions