avh4 / avh4/elm-format

Float constant is changed to incorrect value

Open
#680 12 comments 0 reactions 0 assignees View on GitHub
bug discussion
Dominant language
Haskell
Stars
1.3k
Forks
147
PR merge metrics
No merged PRs in 30d

Description

When I try to define a constant as
```
maxFloatAsFloat : Float
maxFloatAsFloat =
18446744073709549568.0
```
`elm-format` changes that to
```
maxFloatAsFloat : Float
maxFloatAsFloat =
18446744073709550000.0
```

This is incorrect. Value `18446744073709549568.0` can be represented **exactly** as a `Float` unlike `18446744073709550000.0`.

p.s. This is largest possible `Float` value less than `2^64`, i.e. `2^64 - 2048`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the formatting change with the Float constant shown in the issue, then trace elm-format's numeric-literal formatting path. Confirm that formatting preserves the exact value 18446744073709549568.0 rather than changing it to 18446744073709550000.0, and add or update coverage for this case if the relevant test location is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
elm, haskell
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.