Closed ryepesg closed 9 years ago
Can you be more specific about what your proposal is? A "Proposed Change" and "Motivation" section like in https://github.com/elm-lang/elm-plans/issues/7 would greatly help clarify.
"Expected" if you come from the server. On the client, this is JS numbers. Even just 123123517235172351623
evaluates to 123123517235172340000
is JS.
It would be possible to, say, represent larger numbers as arrays or something, but without a concrete use case for numbers that big, I don't see the point in making things more complicated.
Thank you for the comments. I updated the proposal accordingly.
I could see someone writing a BigNumber library for Elm, but I would not want it to be the default implementation for numbers.
The performance cost of wrapping every single number is far more concerning to me than the imprecision of JS doubles!
I'm in the process of closing this repo down. I think this is best as a library. The vast majority of languages just do this so its fast and there are no issues. I don't have strong enough feelings about this topic to really choose a side, so I am going to choose the side that has a better track record.
I think it'd be cool to have a BigInt library though, for folks who are doing that sort of computation.
Now that ES2020 has its native BigInt
support, does it make sense to base the Elm's core Int
on that? I think it would help to do away with oddities of the JS floating point numbers.
Motivation
Elm is a beginner friendly language (this is the reason we have not higher kinded types). I think the integer's limits are not expressed in the documentation because of the complexity of the topic, and people coming from other high level languages doesn't expect to deal with that specific details.
This proposal attempts to codify the ideas from this thread. This would be a breaking change to core, but no change to the language itself.
Proposed Change
Current implementation overflows:
JavaScript doesn't deal with BigNumbers, so the only programs broken programs are those who already had overflows bugs. The expected (even in client side languages like ClojureScript or Scala.js) result is:
Next Steps
To evaluate implementations like https://github.com/maxsnew/BigInt.