RE: [Flashcoders] Flash cant add up!!

2006-08-09 Thread Blumenthal, Peter

It's a simple rounding error between floating point and binary numbers, and
apparent in most (all?) programming languages. Here's a good explanation
from the Python manuakl:

http://docs.python.org/tut/node16.html



Peter Blumenthal
Software Development Manager
Pearson Education
80 Strand, London, WC2R 0RL
Direct Line: +44 (0) 20 7010 2806
Switchboard:  +44 (0) 20 7010 2900


> 
> anyone have any idea why flash does this???
> ___

This email may contain confidential material.  If you were not an
intended recipient, please notify the sender and delete all copies.
We may monitor email to and from our network.
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Flash cant add up!!

2006-08-09 Thread mike cann

oaky great cheers :D

On 09/08/06, Michael Kneib <[EMAIL PROTECTED]> wrote:





http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_13989



Am Mi, 9.08.2006, 16:46, schrieb mike cann:
> Okay, i may be going crazy but slap this on frame one of a flash file
and
>  observe the output:
>
>...
>
> so the res value continues on like that being 0.0996 rather
> than 0.1..
>
>


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Flash cant add up!!

2006-08-09 Thread Michael Kneib



http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_13989



Am Mi, 9.08.2006, 16:46, schrieb mike cann:
> Okay, i may be going crazy but slap this on frame one of a flash file and
>  observe the output:
>
>...
>
> so the res value continues on like that being 0.0996 rather
> than 0.1..
>
>


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Flash cant add up!!

2006-08-09 Thread mike cann

Okay, i may be going crazy but slap this on frame one of a flash file and
observe the output:

//

var incrementNum:Number = 0;
var oldNum:Number = 0;
var resultNum:Number =0;

onEnterFrame = function(){gogo();}

function gogo()
{
   oldNum = incrementNum;
   incrementNum += 0.1;
   resultNum = incrementNum - oldNum;

   trace("old: "+oldNum);
   trace("inc: "+incrementNum);
   trace("res: "+resultNum);
   trace("");
}

stop();

//

For those who dont have the time to test it the output follows like this:

//

old: 0
inc: 0.1
res: 0.1

old: 0.1
inc: 0.2
res: 0.1

old: 0.2
inc: 0.3
res: 0.1

old: 0.3
inc: 0.4
res: 0.1

old: 0.4
inc: 0.5
res: 0.1

old: 0.5
inc: 0.6
res: 0.1

old: 0.6
inc: 0.7
res: 0.1

old: 0.7
inc: 0.8
res: 0.1

old: 0.8
inc: 0.9
res: 0.1

old: 0.9
inc: 1
res: 0.1

old: 1
inc: 1.1
res: 0.1

old: 1.1
inc: 1.2
res: 0.1

old: 1.2
inc: 1.3
res: 0.1

old: 1.3
inc: 1.4
res: 0.1

old: 1.4
inc: 1.5
res: 0.1

old: 1.5
inc: 1.6
res: 0.1

old: 1.6
inc: 1.7
res: 0.1

old: 1.7
inc: 1.8
res: 0.1

old: 1.8
inc: 1.9
res: 0.1

old: 1.9
inc: 2
res: 0.0999

old: 2
inc: 2.1
res: 0.1

old: 2.1
inc: 2.2
res: 0.1

old: 2.2
inc: 2.3
res: 0.1

old: 2.3
inc: 2.4
res: 0.1

old: 2.4
inc: 2.5
res: 0.1

old: 2.5
inc: 2.6
res: 0.1

old: 2.6
inc: 2.7
res: 0.1

old: 2.7
inc: 2.8
res: 0.1

old: 2.8
inc: 2.9
res: 0.1

old: 2.9
inc: 3
res: 0.1

old: 3
inc: 3.1
res: 0.1

old: 3.1
inc: 3.2
res: 0.1

old: 3.2
inc: 3.3
res: 0.1

old: 3.3
inc: 3.4
res: 0.1

old: 3.4
inc: 3.5
res: 0.1

old: 3.5
inc: 3.6
res: 0.1

old: 3.6
inc: 3.7
res: 0.1

old: 3.7
inc: 3.8
res: 0.1

old: 3.8
inc: 3.9
res: 0.1

old: 3.9
inc: 4
res: 0.0996

old: 4
inc: 4.1
res: 0.0996

old: 4.1
inc: 4.2
res: 0.0996

old: 4.2
inc: 4.3
res: 0.0996

old: 4.3
inc: 4.4
res: 0.0996

old: 4.4
inc: 4.5
res: 0.0996

old: 4.5
inc: 4.6
res: 0.0996

old: 4.6
inc: 4.7
res: 0.0996

old: 4.7
inc: 4.8
res: 0.0996

old: 4.8
inc: 4.9
res: 0.0996

old: 4.9
inc: 5
res: 0.0996

old: 5
inc: 5.1
res: 0.0996

old: 5.1
inc: 5.2
res: 0.0996

//

so the res value continues on like that being 0.0996 rather than
0.1..

anyone have any idea why flash does this???
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com