On 2018-01-30 15:35, Michael Budde wrote: > Because of the limited precision of doubles the rounded value of some > numbers cannot be represented. These numbers will be converted to a > rational that /looks/ correct when displayed but does not equal the > true number.
Wonderful, thanks for investigating! > These numbers will be converted to a rational that looks correct when > displayed but does not equal the true number. Of course, this makes sense. I wonder why "ledger eval --unround '(roundto($0.31 / 2, 2))'" doesn't show this imprecision. (Shouldn't it?) I expected round to work differently; something like this maybe? round (a / b, n) // = round (a / b * 10^n, 0) / 10 ^ n // = intpart(a * 10^n / b) / 10 ^ n = (a * 10^n - (a * 10^n mod b)) / 10^n Are there issues with this implementation? (this particular derivation assumes that a and b are positive; it should be adjusted to cover all cases, of course) Cheers, Clément. -- --- You received this message because you are subscribed to the Google Groups "Ledger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
