Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dec type looses precision when compiled on ARM (RPi CM4) #7420

Open
eblade opened this issue Dec 28, 2024 · 0 comments
Open

Dec type looses precision when compiled on ARM (RPi CM4) #7420

eblade opened this issue Dec 28, 2024 · 0 comments
Labels
bug Something isn't working P-medium Medium priority/frequency

Comments

@eblade
Copy link

eblade commented Dec 28, 2024

I am doing exercism exercises for roc on my CM4-based uConsole. It has been working great until the one named Space Age https://exercism.org/tracks/roc/exercises/space-age

Here, large Dec numbers are divided and while the solution works in the repl and on exercism's hardware, it fails when compiled with roc test. The Neptune result is way off. I guess it compiles to some lower resolution type under the hood on ARM.

This is the code for the solution:

module [age]

Planet : [
    Mercury,
    Venus,
    Earth,
    Mars,
    Jupiter,
    Saturn,
    Uranus,
    Neptune,
]

ratio : Planet -> Dec
ratio = \planet -> when planet is
    Mercury -> 0.2408467
    Venus   -> 0.61519726
    Earth   -> 1.0
    Mars    -> 1.8808158
    Jupiter -> 11.862615
    Saturn  -> 29.447498
    Uranus  -> 84.016846
    Neptune -> 164.79132

secondsPerEarthYear : Dec
secondsPerEarthYear = 315.57600

age : Planet, Dec -> Dec
age = \planet, seconds ->
    seconds / 100000 / secondsPerEarthYear / (ratio planet)

And the test that fails:

app [main] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.17.0/lZFLstMUCUvd5bjnnpYromZJXkQUrdhbva4xdBInicE.tar.br",
}

main =
    Task.ok {}

# ...

import SpaceAge exposing [age]
# age on Neptune
expect
    result = age Neptune 1821023456
    Num.isApproxEq result 0.35 { atol: 0.01 }
@Anton-4 Anton-4 added bug Something isn't working P-medium Medium priority/frequency labels Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium Medium priority/frequency
Projects
None yet
Development

No branches or pull requests

2 participants