Closed goldfirere closed 10 years ago
Hi, I am aware of this problem so I've deliverately used Float
there to magnify the problem. I had forgotten to update the comment, which I did. 9dd5b1a7e6daa95cd
The Rational
hack only decreases, not eliminates this kind of problem. I still believe that the rational hack is good, because it should reduce the error-prone floating point multiplication from several times per input-to-exit from twice per input-to-exit. The error will in average increse as square root of the number of float multiplication involved.
It would be interesting to measure this effect in some big computations.
Great -- thanks for updating the comments.
At the end of the Travel.hs test, there is a comment with expected output. Currently, on my machine, the output differs somewhat.
Expected output:
My current output:
Most alarming to me is the second line, with significant rounding error. In examining what's going on, though, this seems somewhat reasonable. The input is 40 mi/gal. Yet, according to the LCSU, this quantity is stored in terms of yards/(cubic yard) -- which is much larger. The precision-saving idea around using
Rational
doesn't really help here, because we are storing the large number between conversions. So, I think that the observed behavior can be considered correct, but I want a second opinion.