Article View: comp.std.c
Article #2188Re: Change to time() fn?
From: Henry Spencer
Date: Fri, 02 Oct 1992 15:43
Date: Fri, 02 Oct 1992 15:43
22 lines
1671 bytes
1671 bytes
In article <1992Sep30.034813.2589@waggen.twuug.com> alpha@waggen.twuug.com (Joe Wright) writes: >Please remember that floats (and doubles) are approximates. >The value of time_t must be precise... It is quite possible to manipulate precise values using doubles, if you have well-behaved floating-point hardware (e.g. IEEE-standard). If your number is an integer that will fit within a double's mantissa field, which is usually 50ish bits, the representation *is* precise. Properly designed floating-point hardware will give precise results when such quantities are added, subtracted, compared, etc., given that neither final nor intermediate results are big enough to exceed the mantissa field. IEEE-standard FP hardware is *required* to do this right. We do a lot of accounting software using awk, which does all its arithmetic using doubles. (The crucial trick is to keep everything in cents rather than fooling around with fractional dollars.) I assure you, we get precise results: our department's accountant notices if a penny is missing. Changing time_t to a double does have problems, but this isn't one of them. -- There is nothing wrong with making | Henry Spencer @ U of Toronto Zoology mistakes, but... make *new* ones. -D.Sim| henry@zoo.toronto.edu utzoo!henry
Technical Details
Message-ID:
<BvI3p8.CAn@zoo.toronto.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!utcsri!utzoo!henryReferences:
<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!utcsri!utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Change to time() fn? Message-ID: <BvI3p8.CAn@zoo.toronto.edu> Date: Fri, 2 Oct 1992 15:43:55 GMT References: <1992Sep29.154252.5453@ima.isc.com> <1992Sep30.034813.2589@waggen.twuug.com> Organization: U of Toronto Zoology Lines: 22