SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old April 30th, 2004, 08:29 AM
formula KZ1000 formula KZ1000 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 formula KZ1000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Bug with multiplication in JavaScript 286.40

There seems to be a bug in Javascript using simple multiplication.

If you times 286.40 times 100 you should get 286.40 but it gives you back 286.39.9999999996.

To prove I am not crazy I have a short script that does just that.

www.myus.com/test.html

I did a search on the net and can not find any info on this.

I know how to get around it I just want to know why such a simple error has not yet been fixed within javascipt.

Or am I clueless and this is not a bug?

Im can't belive I am the first to notice this.

It only seems to do it with this number but there might be others.
Here is the test code that is at the page above.

<script type="text/javascript">
function test() {
var tmp = 0;
tmp = (286.40*100);
alert (tmp);


} // end test function
</script>
<a href="#" onClick="test();">test</a>

286.40

Reply With Quote
  #2  
Old April 30th, 2004, 12:07 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Check out http://www.merlyn.demon.co.uk/pas-real.htm#Float. This doesn't give an exact answer to your specific question, but it suggests that floating point numbers can be tricky. Just because something looks to us like it'd be a round number apparently doesn't mean it is in floating point arithmetic.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old May 3rd, 2004, 11:12 AM
formula KZ1000 formula KZ1000 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 formula KZ1000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
dhouston Thanks,


I am glad I am not going crazy.

Eddie

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Bug with multiplication in JavaScript 286.40


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway