
On 01 February 2005 06:23, Ashley Yakeley wrote:
In article <41FE95DF.50000@cql.com>, Seth Kurtzberg
wrote: I'm not, I hope, being pedantic here and talking about an irrelevant issue. But if you look in any first year engineering textbook (for an engineering discipline other than CS), you will find that the display of a value with a precision greater than the known precision of the inputs is a cardinal sin. It's the wrong answer. The roundoff error behavior is clearly going to be different.
Well, how do you feel about using Rationals everywhere? That way there's never any question of some irrelevant specified unused accuracy.
newtype ClockTime = ClockTime Rational deriving (Eq, etc.)
I quite like the idea of using Rational for ClockTime, but I worry that it might be slow. But it does allow you to do things such as dividing times into n pieces and adding them all up again without error.
Not that keen, I have to say. If we had an Integral type, you can always convert to Rational for the purposes of dividing by 3 and recombining (or whatever) and then use truncate to convert back to Integral. Cheers, Simon

In article
<3429668D0E777A499EE74A7952C382D1031580DD@EUR-MSG-01.europe.corp.microso
ft.com>,
"Simon Marlow"
I quite like the idea of using Rational for ClockTime,
Not that keen, I have to say.
Too slow? I can see that people might want to fetch from the system clock quickly to get accurate time, and with a fairly constant delay, whereas Rational calculation time might be variable. -- Ashley Yakeley, Seattle WA
participants (2)
-
Ashley Yakeley
-
Simon Marlow