[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Negative time
Quoting Bertrand Petit:
> Mzscheme 103 on FreeBSD evaluates (current-milliseconds) to a
> decreasing negative integer:
> [...]
> Is this an expected behavior?
Yes.
> Is it possible to recover from this
> integer the count of milliseconds since the epoch (whatever the epoch
> is)?
`current-seconds' in Unix will reliably report the number of seconds
since the Epoch (Jan 1, 1970 GMT).
`current-milliseconds' in FreeBSD takes `current-seconds', multiplies
it by 1000 using signed 32-bit arithmetic, then adds the number of
milliseconds modulo 1000 since the Epoch using signed 32-bit
arithmetic. Finally, the result is shifted to the left and then back to
the right so that it fits into a fixnum.
So, it's technically possible to compute the number of milliseconds
since the Epoch using those two functions, but it's not easy.
Matthew