LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-07-2004, 04:26 PM
dv8's Avatar
dv8 dv8 is offline

Admin Mod
 
Join Date: Mar 2001
Posts: 2,053
Rep Power: 15
dv8 is on a distinguished road
Question Looping Negative Number Produces Bad Math

I've run into something very strange.
I wrote a small loop to start from -1 and stop at 0 by using a step of .05.
Actionscript:
for (var j = -1; j <= 0; j += .05) {
	trace(j);
}

However my output is not what to be expected
Code:
-1
-0.95
-0.9
-0.85
-0.8
-0.75
-0.7
-0.65
-0.6
-0.55
-0.5
-0.45
-0.4
-0.35
-0.3
-0.25
-0.2
-0.15
-0.0999999999999997
-0.0499999999999997
Why oh why did -0.15 + .05 equal -0.0999999999999997?

Is this bad math? Is this correct math and why?
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Controlling Looping MovieClip Forward and Reverse a Set Number of Frames bkasty ActionScript 3.0 0 08-12-2007 08:48 PM
math locgic need help bad demdps Flash MX ActionScript 3 12-21-2002 04:53 AM
String Arrays to Number Arrays for Math Purpose dv8 Flash 5 Actionscript 2 04-04-2002 10:44 PM
How to calculate a negative random number midjdji Flash 5 Actionscript 15 10-21-2001 06:01 PM
Number to Negative power MixMatch Flash 5 Actionscript 4 10-15-2001 10:23 AM




All times are GMT. The time now is 04:56 PM.