mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-09 22:17:34 +02:00
Flonum/ratio comparison fix from pod.
This commit is contained in:
parent
34a85bf007
commit
a81004672d
2 changed files with 12 additions and 1 deletions
|
@ -1521,7 +1521,8 @@ sexp sexp_compare (sexp ctx, sexp a, sexp b) {
|
||||||
break;
|
break;
|
||||||
#if SEXP_USE_RATIOS
|
#if SEXP_USE_RATIOS
|
||||||
case SEXP_NUM_FLO_RAT:
|
case SEXP_NUM_FLO_RAT:
|
||||||
r = sexp_make_fixnum((sexp_sint_t)(sexp_flonum_value(a) - sexp_ratio_to_double(b)));
|
f = sexp_flonum_value(a) - sexp_ratio_to_double(b);
|
||||||
|
r = sexp_make_fixnum(f > 0.0 ? 1 : f == 0.0 ? 0 : -1);
|
||||||
break;
|
break;
|
||||||
case SEXP_NUM_FIX_RAT:
|
case SEXP_NUM_FIX_RAT:
|
||||||
case SEXP_NUM_BIG_RAT:
|
case SEXP_NUM_BIG_RAT:
|
||||||
|
|
|
@ -119,4 +119,14 @@
|
||||||
(-18446744078004518913 -18446744069414584321 79228162514264337597838917632 4294967296 -1))
|
(-18446744078004518913 -18446744069414584321 79228162514264337597838917632 4294967296 -1))
|
||||||
(sign-combinations (+ 1 (expt 2 64)) (expt 2 32)))
|
(sign-combinations (+ 1 (expt 2 64)) (expt 2 32)))
|
||||||
|
|
||||||
|
(cond-expand
|
||||||
|
(ratios
|
||||||
|
(test #t (< 1/2 1.0))
|
||||||
|
(test #t (< 1.0 3/2))
|
||||||
|
(test #t (< 1/2 1.5))
|
||||||
|
(test #t (< 1/2 2.0))
|
||||||
|
(test 1.0 (max 1/2 1.0)))
|
||||||
|
(else
|
||||||
|
#f))
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
Loading…
Add table
Reference in a new issue