-
Notifications
You must be signed in to change notification settings - Fork 15
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
Range size larger than integer range #80
Comments
The compelling part of your example is this:
You found a way to construct an integer value outside of the allowed range, and that's clearly a bug. In #81 you propose to fix it by disallowing large ranges. You are right that strings and arrays are less suspectible to the same problem, but the JS spec allows these structures to grow really huge, so when fixing ranges we should consequently also fix string, array and dictionary. I agree that practically speaking there is no need, but it would be odd to leave this open. I see two possible remedies:
The principle of least surprise and the fact that these limits are quite generous indicate that the first solution is preferable. I'll merge #81 but leave this open, since strings and containers should be addressed eventually (low priority). |
This comment has been minimized.
This comment has been minimized.
Yeah, obviously :) Thanks. |
An alternative could be to think about a big integer type like in Python, that is only limited by the available memory. |
That's true, it would nicely solve the issue in the language. However, one of the learning goals is to understand the two-complement representation of signed integers. Understanding the inner working mechanisms of integers would then become more involved. Code complexity would also increase, since all integer operations need to be implemented manually (+, -, *, //, %, not, and, or, xor, as well as conversion to floating point numbers). I am not sure that it is worth it. |
While JavaScript does have a |
Good to know, I had no idea! Anyway, I agree. |
Description
Ranges can have a size larger than the allowed range for Integers. This can be used to proof that, oppsed to what some tests may claim, TScripts for loops are turing complete (at least in the only tscript runtime).
To Reproduce
Arrays and strings however are safe(r) since it would be impracticable to create one of them with a size larger than 2147483647. They are also respectivly bounded by 2^32 and 2^53 -1.
The text was updated successfully, but these errors were encountered: