[Javascript] INCREDIBLE IE BUG!!!!

Muchacho, Laurent (TWIi London) LMuchacho at twii.net
Wed Oct 15 08:34:27 CDT 2003


Hi All 

A friend found this on the subject it did the trick for me on what I had to
do at the time. 

	var a = '1.23456789'
	alert(RoundToNdp(a,4));

	// Round to N number of decimal points:
	function RoundToNdp(X, N){
		var T = Number('1e'+N)
		return Math.round(X*T)/T
	}

the whole article
http://www.merlyn.demon.co.uk/js-round.htm

Laurent


-----Original Message-----
From: Chris Basken [mailto:chriz at basken.com]
Sent: 13 October 2003 19:04
To: [JavaScript List]
Subject: Re: [Javascript] INCREDIBLE IE BUG!!!!


Yes.  When I worked on an accounting page, I was informed by the client's
bank that internally they convert all money to the lowest possible
demonination (pennies, for American currency, for example), do the math like
that, then convert back.

So you may have $500.00 in your checking account, but the bank sees it as
50,000¢.

>
>     Dang.  So now we need to round whenever performing floating point
> operations...
>
>     Any idea if this happens on previous versions of IE?
>
> -Peter
>
> -----Original Message-----
> From: javascript-bounces at LaTech.edu On Behalf Of Dan Costea
>
>     Hi to all,
>
> If I'm blind or dreaming, please, let me know, but, try this first:
>
> It's easy to make the following sum in your head:  0.15 + 0.015 = 0.165
> (OBVIOUS!)
>
> TRY THIS IN YOUR IE 6 WITH SP1:  alert (0.15 + 0.015); you will obtain:
> 164999999999999998
> OR:
> alert (0.15 + 0.015 - 0.15 - 0.015);  - I think the result is obvious
> for any human, but not for IE, that will return: -1.3877787807814457e-17
> (that indeed, is almost 0, but not realy 0...).
>
> I still can't believe it! And of course, those are not special numbers.
> You can find many, many more (ex: 0.15+0.075, or 0.14+0.016) - I think
> the bug is in the cases that the sum of the last digit of each number is
> 10, and the number of digits representing the precision is different.
>
> Regards,
> Dan Costea.
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>



_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript


DISCLAIMER - The preceding e-mail message (including any attachments)
contains information that may be confidential, may be protected by the
attorney-client or other applicable privileges, or may constitute non-public
information.  It is intended to be conveyed only to the designated
recipient(s) named above.  If you are not an intended recipient of this
message, or have otherwise received it in error, please notify the sender by
replying to this message and then delete all copies of it from your computer
system.  Any use, dissemination, distribution, or reproduction of this
message by unintended recipients is not authorized and may be unlawful. The
contents of this communication do not necessarily represent the views of
this company.



More information about the Javascript mailing list