The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Decimal places return 'wrong' value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 11/10/2003 :  3:04:29 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

Is this a bug or 'expected/normal' behaviour : if the number of decimal digits is set to >14 then $(14.7) returns 14.699999999999999.

Cheers,

Pete

greg

USA
1379 Posts

Posted - 11/10/2003 :  5:33:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Computers have limited abilities when it comes to storing numbers. In particular, storing numbers in the 'double' format limits precision to about 15 or 16 decimal digits.
When you give a decimal value - like 14.7 - to a computer, that number gets converted to the binary format needed to store that number (as type double). In fact, for certain decimal values, this process yields a binary number that is as close as you can get to the real value, but not exact. One bit 'more' or one bit 'less' would be even further away from the real value.
So this is a fact of computer life that programmers should be aware of and deal with in their code.


Go to Top of Page

peter.cook

UK
356 Posts

Posted - 11/12/2003 :  04:02:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for explanation Greg.

Cheers,

Pete

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000