I tried storing 1016 - 1 in a Number
variable:
var n:Number = 9999999999999999
but the value stored in n
ends up being 10000000000000000, or 1017.
How can I represent 1016 - 1 in actionscript 3?
You've ran out of Number type precision capability, so you'll have to devise your own way to store numbers this big with the required precision. One of the most common way to operate long arithmetic is using strings as data holders, another is using a vector of ints, each position representing a "big digit" of a 2^32 based system. Given AS3 constraints, I'd say a vector of ints would be faster, although displaying a long number will be easier with string based approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With