A tiny change would enable BigInt to work in Snap!

If one just puts 'n' at the end of an integer you get bignums in nearly all modern browsers.

But I can't type 999999999999999999999999999999n to Snap! blocks. If I could then all arithmetic blocks would automatically support big integers.

Yes, this would not address the support for rational numbers and more that the BigNum library currently supports. But this would work without loading any libraries.

I'd imagine that if it was that simple, then Snap! would just have a flag to allow adding an n to the end of numbers in numeric slots :slight_smile:

While this has been supported in Chrome for 3 years and FireFox for 2, I see that Safari first release supporting it was in September.

Users who put an 'n' at the end of their integers do have to put up with errors due to mixing big ints and ordinary numbers.

Yeah this is kind of a deal-killer. But if you want to use it anyway, just write an ID block that reports its input to escape from the restrictions of the Number-type input slot.

I tried it and got an error due to

Process.prototype.reportBasicSum = function (a, b) {
    return +a + (+b);

while editing it to

Process.prototype.reportBasicSum = function (a, b) {
    return a + b;

And it works fine.

So supporting Big Integers isn't that straight-forward since Snap! uses +x to convert possible strings to numbers.


I guess it does limit the use cases significantly.

Oh well. I'm OK with closing this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.