ANSI C.

Tom Jaskiewicz tj at alliant.UUCP
Thu Jan 23 09:38:26 AEST 1986


In article <618 at baylor.UUCP> peter at baylor.UUCP (Peter da Silva) writes:
>> difftime() accepts time_t arguments but returns a double.
>
>What's wrong with returning a long?

1.  time_t may give millisecond resolution (or microseconds (or nanoseconds))
which you really want to have.

2.  difftime may need to return a value larger than 2**32 (not likely but
possible).

In short, you want the range that floating point provides for you.

>What's wrong with having a function:
>
>long seconds(time)
>time_t time;

Nothing really.  But I would rather use difftime *unless* I had a good
reason not to, such as running on a machine where

>doing any floating point arithmetic in a program adds
>quite a bit of overhead.
-- 
####################################################################
# uucp:  decvax!linus!alliant!tj ## Bernese are mountains of love. #
####################################################################



More information about the Comp.lang.c mailing list