Represent 9999999999999999 in actionscript 3

无人久伴 提交于 2019-12-10 17:33:33

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/12742177/represent-9999999999999999-in-actionscript-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!