actionscript 3 - Decimal numbers not adding correctly in AS3 -


this question has answer here:

in program, have score multiplier variable of type 'number' when try add 0.1 it, have problem. here code:

scoremultiplier += 0.1; trace(scoremultiplier); 

scoremultiplier set 1, , after first run through, correctly value of 1.1. however, second time, trace shows 1.2000000000000002, , next time 1.3000000000000003.

there no other code modifies scoremultiplier. problem, first because shown on game screen , goes off screen, , second because if conditionals scoremultiplier==2 example not work due bizarre fault in addition.

if knows what's causing this, or @ least how truncate value 1 decimal place, great.

flash not floating points. @ all. avoid them as can.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -