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

Bug: Integer Precision on PC versus Mac #696

Closed
blogscot opened this Issue Aug 22, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@blogscot

blogscot commented Aug 22, 2016

While trying to solve an exercism.io problem, I encountered the following issue:

On Windows 10 PC, Elm 0.17.1:

> a = 2329871239
-1965096057 : number
> a = 2329871239.0
2329871239 : Float

While on Mac OS X, Elm 0.17.1

a = 2329871239
2329871239 : number
> a = 2329871239.0
2329871239 : Float

This problem was discussed on the Elm Slack Channel, where it was confirmed that this issue was present on an independent Windows 10 machine running the same Elm version.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Aug 22, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Aug 22, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Aug 29, 2016

Member

This is due to the fact that Elm compiles to JS. Unless JS is different, or unless we compile to some other thing, I see no practical way to do anything about this. If there is some concrete proposal, we can talk about that in a new issue.

Member

evancz commented Aug 29, 2016

This is due to the fact that Elm compiles to JS. Unless JS is different, or unless we compile to some other thing, I see no practical way to do anything about this. If there is some concrete proposal, we can talk about that in a new issue.

@evancz evancz closed this Aug 29, 2016

@blogscot

This comment has been minimized.

Show comment
Hide comment
@blogscot

blogscot Aug 30, 2016

Is this problem described above really a limitation of JS?

Chrome Output:

a = 2329871239
2329871239
a = 232987123992349237492734987234897239472394729347289
2.3298712399234924e+50
a = 2329871239923492374927349872348972394723947293472892304892309482034802348023948023984023984230948203480239482308402340238
2.3298712399234923e+120

Elm repl output

λ elm-repl
---- elm-repl 0.17.1 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> a = 2329871239
-1965096057 : number
> a = 232987123992349237492734987234897239472394729347289
-1140926247 : number
> a = 2329871239923492374927349872348972394723947293472892304892309482034802348023948023984023984230948203480239482308402340238
179298702 : number

Iain

blogscot commented Aug 30, 2016

Is this problem described above really a limitation of JS?

Chrome Output:

a = 2329871239
2329871239
a = 232987123992349237492734987234897239472394729347289
2.3298712399234924e+50
a = 2329871239923492374927349872348972394723947293472892304892309482034802348023948023984023984230948203480239482308402340238
2.3298712399234923e+120

Elm repl output

λ elm-repl
---- elm-repl 0.17.1 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> a = 2329871239
-1965096057 : number
> a = 232987123992349237492734987234897239472394729347289
-1140926247 : number
> a = 2329871239923492374927349872348972394723947293472892304892309482034802348023948023984023984230948203480239482308402340238
179298702 : number

Iain

@blogscot

This comment has been minimized.

Show comment
Hide comment
@blogscot

blogscot Aug 30, 2016

Ubuntu blows up after 18 steps:

---- elm-repl 0.17.1 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> a = 10
10 : number
> a = 100
100 : number
> a = 1000
1000 : number
> a = 10000
10000 : number
> a = 100000
100000 : number
> a = 1000000
1000000 : number
> a = 10000000
10000000 : number
> a = 100000000
100000000 : number
> a = 1000000000
1000000000 : number
> a = 10000000000
10000000000 : number
> a = 100000000000
100000000000 : number
> a = 1000000000000
1000000000000 : number
> a = 10000000000000
10000000000000 : number
> a = 100000000000000
100000000000000 : number
> a = 1000000000000000
1000000000000000 : number
> a = 10000000000000000
10000000000000000 : number
> a = 100000000000000000
100000000000000000 : number
> a = 1000000000000000000
1000000000000000000 : number
> a = 10000000000000000000
-8446744073709552000 : number

Windows blows up after 9 steps:

λ elm-repl
---- elm-repl 0.17.1 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> a = 10
10 : number
> a = 100
100 : number
> a = 1000
1000 : number
> a = 10000
10000 : number
> a = 100000
100000 : number
> a = 1000000
1000000 : number
> a = 10000000
10000000 : number
> a = 100000000
100000000 : number
> a = 1000000000
1000000000 : number
> a = 10000000000
1410065408 : number
> a = 100000000000
1215752192 : number
> a = 1000000000000
-727379968 : number

blogscot commented Aug 30, 2016

Ubuntu blows up after 18 steps:

---- elm-repl 0.17.1 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> a = 10
10 : number
> a = 100
100 : number
> a = 1000
1000 : number
> a = 10000
10000 : number
> a = 100000
100000 : number
> a = 1000000
1000000 : number
> a = 10000000
10000000 : number
> a = 100000000
100000000 : number
> a = 1000000000
1000000000 : number
> a = 10000000000
10000000000 : number
> a = 100000000000
100000000000 : number
> a = 1000000000000
1000000000000 : number
> a = 10000000000000
10000000000000 : number
> a = 100000000000000
100000000000000 : number
> a = 1000000000000000
1000000000000000 : number
> a = 10000000000000000
10000000000000000 : number
> a = 100000000000000000
100000000000000000 : number
> a = 1000000000000000000
1000000000000000000 : number
> a = 10000000000000000000
-8446744073709552000 : number

Windows blows up after 9 steps:

λ elm-repl
---- elm-repl 0.17.1 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> a = 10
10 : number
> a = 100
100 : number
> a = 1000
1000 : number
> a = 10000
10000 : number
> a = 100000
100000 : number
> a = 1000000
1000000 : number
> a = 10000000
10000000 : number
> a = 100000000
100000000 : number
> a = 1000000000
1000000000 : number
> a = 10000000000
1410065408 : number
> a = 100000000000
1215752192 : number
> a = 1000000000000
-727379968 : number
@lukewestby

This comment has been minimized.

Show comment
Hide comment
@lukewestby

lukewestby Aug 30, 2016

Member

@evancz it looks like some part of this issue does have to do with the compiler. compiling this Elm:

module Main exposing (..)

a =
    1000000000000000000000

results in this JavaScript:

var _user$project$Main$a = 3875820019684212736;

I'm going to open a bug on the compiler

There's a bug on elm-compiler about this already: elm/compiler#1246

Member

lukewestby commented Aug 30, 2016

@evancz it looks like some part of this issue does have to do with the compiler. compiling this Elm:

module Main exposing (..)

a =
    1000000000000000000000

results in this JavaScript:

var _user$project$Main$a = 3875820019684212736;

I'm going to open a bug on the compiler

There's a bug on elm-compiler about this already: elm/compiler#1246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment