On 18 mai, 20:05, "Somebody" <someb...@cox.netwrote:
Quote:
Quote:
That way, in my case off 1/3, I'll be able to fully recover the original
value. Ie...:
Not unless your doubles use a base 3, or a power of 3.
Quote:
Huh? What does this have to do with 3's?
The fraction 1/3 will only be exactly representable in a double
if the base of the double is 3 or a multiple of 3.
Quote:
My point was, in the case of a 1/3 ratio (or any ratio with an
infinite repeating decimal), I'll never be able to recalculate
the numerator exactly given the denomenator and ratio.
Quote:
But by storing the numerator and denomenator as ints instead
of a ratio, I would.
That's one solution. If the target value is an int, after
rescaling, it's probable that the double will store the ratio
with enough precision, provided that you round the results
correctly.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34