Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Represent 9999999999999999 in actionscript 3

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?

like image 624
Muzzlightyear Avatar asked Dec 03 '22 01:12

Muzzlightyear


1 Answers

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.

like image 141
Vesper Avatar answered Dec 31 '22 07:12

Vesper