Introduce 99999999999999999 in ActionScript 3

I tried to save 10 16 - 1 in the Number variable:

 var n:Number = 9999999999999999 

but the value stored in n ends with 10000000000000000 or 10 17 .

How can I represent 10 16 - 1 in actionscript 3?

+4
source share
1 answer

You have run out of precision numbers like Number, so you have to develop your own way of storing numbers with great accuracy. One of the most common ways to work with long arithmetic is to use strings as data holders, and the other is an ints vector, each position is a "big digit" of a 2 ^ 32-based system. Given the limitations of AS3, I would say that the vector ints will be faster, although displaying a long number will be easier with the string approach.

+17
source

Source: https://habr.com/ru/post/1437955/


All Articles