🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2192

Re: Change to time() fn?

#2192
From: Peter Holzer
Date: Fri, 02 Oct 1992 17:27
25 lines
1706 bytes
alpha@waggen.twuug.com (Joe Wright) writes:

>Please remember that floats (and doubles) are approximates.
>The value of time_t must be precise.  We don't like a value
>which says 'it's almost 5 o'clock'.  Precision requires
>time_t to be an integer.

But it is the other way round. When your clock says `it is 5 o'clock',
it isn't exactly 5 o'clock, but a little earlier or later (even if the
clock is exact, the information will be outdated by the time it gets to
the CPU). Also, floats and doubles are just as exact as integers---they
have a finite set of values they can represent exactly. If you want to
represent a value which is not in that set you have choose the
nearest representable value or admit it can't be done.

As a side note, the IEEE double has 53 bits of mantissa, so you can
represent the integers -(2**52-1) ... 2**52-1 exactly, which is a much
larger range than long offers on most implementations.

	Peter
-- 
|    _  | Peter J. Holzer                       | Think of it   |
| |_|_) | Technical University Vienna           | as evolution  |
| | |   | Dept. for Real-Time Systems           | in action!    |
| __/   | hp@vmars.tuwien.ac.at                 |     Tony Rand |
Technical Details
Message-ID: <1992Oct2.172740.9426@email.tuwien.ac.at>
Path: arc1-ca.pugleaf.net!sparky!uunet!email!hp
References: <1992Sep29.154252.5453@ima.isc.com> <1992Sep30.034813.2589@waggen.twuug.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!email!hp
From: hp@vmars.tuwien.ac.at (Peter Holzer)
Subject: Re: Change to time() fn?
Message-ID: <1992Oct2.172740.9426@email.tuwien.ac.at>
Sender: news@email.tuwien.ac.at
Nntp-Posting-Host: quasi.vmars.tuwien.ac.at
Organization: Technical University Vienna, Dept. for Realtime Systems, AUSTRIA
References: <1992Sep29.154252.5453@ima.isc.com> <1992Sep30.034813.2589@waggen.twuug.com>
Date: Fri, 2 Oct 1992 17:27:40 GMT
Lines: 25