Time Resolution

Simon Marlow simonmar at microsoft.com
Tue Feb 1 04:45:04 EST 2005

On 01 February 2005 06:23, Ashley Yakeley wrote:

> In article <41FE95DF.50000 at cql.com>, Seth Kurtzberg <seth at cql.com>
> 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


More information about the Libraries mailing list