Majestics
Practically a Master Poster
696 posts since Jul 2007
Reputation Points: 209
Solved Threads: 66
Skill Endorsements: 5
Floating point numbers are represented in binary fractions. (1/2 + 1/4 + 1/8 + 1/16 etc). You fractional value is 0.3, ie 3/10. There is no exact way to represent 3/10 using only binary fractions, so the answer has to be slightly wrong. This is true of all floating point arithmetic on all binary computers.
When using floating point you must always be aware of this, and be ready to round your output to the right number of decimal places when you print it.
JamesCherrill
... trying to help
8,502 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29
Question Answered as of 1 Year Ago by
JamesCherrill,
Bladtman242
and
Majestics