I may be confused about what you're trying to do, but I think you're under the 
impression that floating point numbers are stored in a base 10 format. In fact, 
they're stored in base 2, with a base 2 exponent. Therefore, it may not be possible to 
exactly represent the number without non-zero garbage digits.

What John was getting at, I think, it the notion that if you're using floating point 
numbers, you always need to keep track of how much useful data there is in the number. 
This can be done using significant figures or by calculating errors. If you're looking 
for results which are correct down to the last digit, you probably shouldn't be using 
them at all. There are more appropriate representations for such calculations. Often, 
the best choice is a fixed point representation. If you're working with numbers 
entered by the user, you may want to avoid round-off induced by base conversion by 
storing numbers in the same base as they're entered (or a power of that base).
--
Peter Epstein
Palm Inc. Developer


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to