我正在冷聚变式中作如下行动说明:
页: 1
我:
24.3243243243243
计算器给我:
24.32432432432432
Note the extra 2 at the end.
因此,当我试图拿到24.32432432243 * 3.7,然后我拿到89.99999999999美元时,我就会出现问题。 这是错误的。
为什么行动说明拖延了价值,我如何避免这样做,这样我就获得计算员获得的适当数额?
非常感谢。
我正在冷聚变式中作如下行动说明:
页: 1
我:
24.3243243243243
计算器给我:
24.32432432432432
Note the extra 2 at the end.
因此,当我试图拿到24.32432432243 * 3.7,然后我拿到89.99999999999美元时,我就会出现问题。 这是错误的。
为什么行动说明拖延了价值,我如何避免这样做,这样我就获得计算员获得的适当数额?
非常感谢。
圆桌会议
var toFixed:Function = function(number, factor) {
return (Math.round(number * factor)/factor);
}
Where the factor is 10, 100, 1000 etc, a simple way to think about it is the number of 0 s in the factor is the number of decimal places
......
页: 1
Good explanation of numeric in ActionScript can be found at http://docstore.mik.ua/orelly/web2/action/ch04_03.htm. See section 4.3.2.1. Floating-point precision
A relavant quote:
“为了弥补时间上的不一致,如果差异会对你的代码的行为产生不利影响,你应人工打上你的号码。 “......
Need a code that only accepts numbers. Upon inputting, the code must check if it is number, if not, it must remove the entered key or not enter it at all
Context : I m working on a Flash application developed with FDT and compiled with Flash CS4 (I need a huge library). It should connect to various Weborb services. Weborb is properly configured. My ...
I have a for loop in action script which I m trying to use to dynamically create variable. Example for( i = 0 ; i < 3 ; i++) { var MyVar+i = i; } after this for loop runs, i would like to ...
I m trying to create a simple loop that adds a random number of stars, fades them out and removes them. The script I ve come up with does everything but remove them, and perhaps I need a less on ...
Could someone please let me know if is possible to drag (multiple) files from desktop directly into a flash webpage. If yes could you please link me to some online resources.
I have a XMLSocket and I call send twice in the same function. The first send works but the second does not? Does XMLSocket have a restriction to only send one message per frame? Do I have to queue ...
I have a function that I want to run at an interval within a frame. I use the following code to start the function: var intervalID = setInterval(intervalFunction, 3000); Then, in a button s ...
I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...