Re: Weird problem ( 3 * 31.9 = 95.699999999999 99)
JRS: In article <veyvhzw8.fsf@h otpop.com>, dated Mon, 14 Nov 2005
19:01:43, seen in news:comp.lang. javascript, Lasse Reichstein Nielsen
<lrn@hotpop.com > posted :
[color=blue]
>In Javascript, all numbers are floating point numbers (more preciely
>64 bit floating point numbers as defined in IEEE-754, the kind typically
>implemented by the CPU as well). There is no difference between "3" and
>"3.0" as a number literal.
>
>The 64 bit floats can represent all integers up to 2^54 precisely, and
>do exact integer arithmetic with them.[/color]
But Math.pow(2, 54) - 1 is even, as is Math.pow(2, 53) + 1 ;
you mean up to (and including) 2^53 (and down to include -2^53).
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
JRS: In article <veyvhzw8.fsf@h otpop.com>, dated Mon, 14 Nov 2005
19:01:43, seen in news:comp.lang. javascript, Lasse Reichstein Nielsen
<lrn@hotpop.com > posted :
[color=blue]
>In Javascript, all numbers are floating point numbers (more preciely
>64 bit floating point numbers as defined in IEEE-754, the kind typically
>implemented by the CPU as well). There is no difference between "3" and
>"3.0" as a number literal.
>
>The 64 bit floats can represent all integers up to 2^54 precisely, and
>do exact integer arithmetic with them.[/color]
But Math.pow(2, 54) - 1 is even, as is Math.pow(2, 53) + 1 ;
you mean up to (and including) 2^53 (and down to include -2^53).
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Comment