Sujet : Re: "A diagram of C23 basic types"
De : cr88192 (at) *nospam* gmail.com (BGB)
Groupes : comp.lang.cDate : 14. Apr 2025, 19:36:07
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vtjknt$1sp26$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Mozilla Thunderbird
On 4/14/2025 12:40 PM, candycanearter07 wrote:
Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 04:33 this Monday (GMT):
On Mon, 7 Apr 2025 21:49:02 +0200, Janis Papanagnou wrote:
>
A better unit is, IMO, a second resolution (which at least is a basic
physical unit) and a separate integer for sub-seconds.
>
I worked out that an integer of a little over 200 bits is sufficient to
represent the age of the known Universe in units of the Planck interval
(5.39e-44 seconds). Therefore, rounding to something more even, 256 bits
should be more than enough to measure any physically conceivable time down
to that resolution.
The problem then becomes storing that size.
More practical is storing the time in microseconds.
A 64-bit integer holding the time in microseconds covers pretty much the entirety of human history thus far.
It is accurate enough to express the time for most conventional timing tasks.
Granted, needing to divide by 1000000 to get the time in seconds is a mild annoyance.
For some use cases, could do an approximation, say:
time_sc=time+(time>>5)+(time>>6)+(time>>10)+(time>>11);
time_sec=time_sc>>20;
Say, pre-scaling the time to be approximately a power-of-2 fraction and then shifting right, which could be faster (and close enough) on targets where 64 bit multiply and divide are painfully slow.
...