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
 All Forums
 Origin Forum
 Origin Forum
 Decimal places return 'wrong' value

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
peter.cook Posted - 11/10/2003 : 3:04:29 PM
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

2   L A T E S T    R E P L I E S    (Newest First)
peter.cook Posted - 11/12/2003 : 04:02:06 AM
Thanks for explanation Greg.

Cheers,

Pete

greg Posted - 11/10/2003 : 5:33:30 PM
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.



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000