Guess that is why it is called "floating" point. ;-)

Shawn


-----Original Message-----
From: Brian Eckerman [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 1:45 PM
To: CF-Talk
Subject: RE: *CRITCAL FLAW* final & fix


Great, thankyou for the answer, but lol get this when you ((n*10)+.5)/10
it mucks it up again and will give you something like 12.400000000000000001.
Just dividing the thing confuses it.  I give up.  I'll just try not to use
Javascript for 
dynamic math.

(p.s. I did stumble apon a hack/temporary fix)
(go to http://www.spiderpro.com/bu/bujvsh002.html)







-----Original Message-----
From: Shawn McKee [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 2:10 PM
To: CF-Talk
Subject: RE: *CRITCAL FLAW*


Not sure how many programming languages you have used but this is not all
that unusual with floating point numbers.  You need to do some work to get
the significant bits you care about if it really matters.  Doing equality
checks on floating point math is generally a problem.

For instance this:

<script> alert(12.1+.1+.1+.1);</script>

On my system gives back 12.399999999999999 in Netscape and
12.399999999999998 in IE.

As I recall from my BASIC/FORTRAN/C/C++ days we generally multiplied by a
factor to move everything we cared about to the left of the decimal then
added .5, floored the whole thing and then divided it back by the factor.

<script> alert(Math.floor((((12.1+.1+.1+.1) * 10) + .5)) /10);</script>

Shawn McKee
Manager, Web Development
NewsStand, Inc.
8620 Burnet Rd., Suite 100
Austin, TX 78757 USA
512-334-5100
Read newspapers and magazines from around the world in a whole new way.
NewsStand delivers them to your PC without paper and without delay!
Try: http://www.newsstand.com?NSEMC=EMNSI000001



        

-----Original Message-----
From: Brian Eckerman [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 12:49 PM
To: CF-Talk
Subject: RE: *CRITCAL FLAW*


no i'm trying to take    and it comes out to 12.40000000001 

ARRRGGGGGHHHHHH this is cripling

-----Original Message-----
From: Critter [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 1:18 PM
To: CF-Talk
Subject: Re: *CRITCAL FLAW*


oi Brian!!

are you using parseFloat() ?


-- 
Critz
Certified Adv. ColdFusion Developer

Crit[s2k] - <CF_ChannelOP Network="Efnet" Channel="ColdFusion">
------------------------------------
Monday, July 1, 2002, 1:11:59 PM, you wrote:

BE> I know this is WAY of track, but what the heck is up with
BE> the way Javascript messes up floating point numbers.

BE> Sheesh.
BE> 




______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to