[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26162: time-duration screws up negative durations
From: |
Zefram |
Subject: |
bug#26162: time-duration screws up negative durations |
Date: |
Sat, 18 Mar 2017 22:17:42 +0000 |
Computing a difference between two SRFI-19 times, using time-difference,
produces sensible results if the result is positive, but often nonsense
if it's negative:
scheme@(guile-user)> (use-modules (srfi srfi-19))
scheme@(guile-user)> (time-difference (make-time time-tai 0 1) (make-time
time-tai 1000 0))
$1 = #<time type: time-duration nanosecond: 999999000 second: 0>
scheme@(guile-user)> (time-difference (make-time time-tai 1000 0) (make-time
time-tai 0 1))
$2 = #<time type: time-duration nanosecond: 1000001000 second: 0>
The above is computing the same interval both ways round. The first time
is correct, but the second is obviously not the negative of the first.
The correct result for the second would be
#<time type: time-duration nanosecond: 1000 second: -1>
or possibly, at a stretch,
#<time type: time-duration nanosecond: -999999000 second: 0>
(SRFI-19 isn't clear about which way it's meant to be normalised.
Having the nanoseconds field always non-negative is less surprising and
easier to maintain through computation.)
-zefram
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#26162: time-duration screws up negative durations,
Zefram <=