bc: avoid bad floating-point roundoff in seconds->date
Thanks, Xsmith! Closes #3489
This commit is contained in:
parent
09c9901f6b
commit
7c8d9c6523
|
@ -128,4 +128,10 @@
|
|||
(err/rt-test (seconds->date (expt 2 50)) out-of-range)
|
||||
(err/rt-test (seconds->date (expt 2 60)) out-of-range)))
|
||||
|
||||
;; Check inexact arithmetic
|
||||
(test (seconds->date 0 #f)
|
||||
seconds->date 0.1e-16 #f)
|
||||
(test (date* 59 59 23 31 12 1969 3 364 #f 0 999999999 "UTC")
|
||||
seconds->date -0.1e-16 #f)
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -9790,6 +9790,8 @@ static Scheme_Object *seconds_to_date(int argc, Scheme_Object **argv)
|
|||
if (SCHEME_INTP(secs) || SCHEME_BIGNUMP(secs)) {
|
||||
nsecs = scheme_make_integer(0);
|
||||
} else {
|
||||
p[0] = secs;
|
||||
secs = scheme_inexact_to_exact(1, p);
|
||||
nsecs = secs;
|
||||
p[0] = secs;
|
||||
secs = scheme_floor(1, p);
|
||||
|
|
Loading…
Reference in New Issue
Block a user