Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDocumentation: What is an Int? #742
Comments
jvoigtlaender
added
the
docs
label
Oct 30, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sgraf812
Oct 31, 2016
Also, the usual weird JavaScript hacks exist if you are concerned about precision. I'm making use of this in intdict, requiring the user to make sure they are actually passing valid integers (yuck!).
Perhaps something like this is worthwhile to have in core?
sgraf812
commented
Oct 31, 2016
|
Also, the usual weird JavaScript hacks exist if you are concerned about precision. I'm making use of this in Perhaps something like this is worthwhile to have in |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Nov 1, 2016
Member
Because Elm targets JavaScript, there are certain problems with integers that we cannot fix without very severe performance costs. An Elm Int should be a 32-bit integer, but there is no such thing in JavaScript. So you can think of this as the compiler being non-compliant. The problem is that compliance is basically impossible until we are targeting WebAssembly directly, or some other platform.
One of my goals with Elm is that we should never willingly inherit silly JavaScript problems. This is a case where the language is designed aspirationally, so when the day comes that we can have real integers (through whatever means) Elm does not end up being dumb.
Does that answer your question? Also, I don't know where this should be documented. If someone can find a nice place, maybe it makes sense to do.
|
Because Elm targets JavaScript, there are certain problems with integers that we cannot fix without very severe performance costs. An Elm One of my goals with Elm is that we should never willingly inherit silly JavaScript problems. This is a case where the language is designed aspirationally, so when the day comes that we can have real integers (through whatever means) Elm does not end up being dumb. Does that answer your question? Also, I don't know where this should be documented. If someone can find a nice place, maybe it makes sense to do. |
evancz
closed this
Nov 1, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
expipiplus1
Nov 5, 2016
Would it be possible to keep this issue open until this information finds a place in the documentation?
expipiplus1
commented
Nov 5, 2016
|
Would it be possible to keep this issue open until this information finds a place in the documentation? |
referenced
this issue
in expipiplus1/elm-export
Nov 5, 2016
expipiplus1
referenced this issue
Nov 5, 2016
Open
Remove ElmType instances of non-32bit int types #17
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
This sounds like a good addition to http://faq.elm-community.org |
expipiplus1 commentedOct 30, 2016
I've been unable to determine what is representable in a value of type
Intin Elm.This page seems to suggest that
Intis a 32bit two's complement integer http://learnyouanelm.github.io/pages/03-types.htmlPlaying around in the REPL suggests that Int is actually represented as a double precision float. 2^53 is the largest value such that every positive integer below it is representable.