Skip to content

toFixedNative uses %d (integer) format, truncating floats #3

@Unisay

Description

@Unisay

Found while fixing #1. Data/Number/Format.lua toFixedNative formats with %d (or otherwise an integer conversion) where the upstream JS toFixed keeps fractional digits. Result: fractional values are truncated to integers instead of rounded to the requested number of decimals.

Reproduce: Data.Number.Format.toStringWith (fixed 2) 3.14159 should give "3.14" but yields the integer-truncated form.

Fix: use %.<d>f so the requested decimal precision is honored; add a golden/eval covering a fractional value.

Separate from #1 (unbound number variable), which is already fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions