fix inexact->exact on subnormal single-flonums and extflonums

Closes #2223
This commit is contained in:
Matthew Flatt 2018-08-11 15:53:34 -06:00
parent cf396064c3
commit 89583a4d03
3 changed files with 10 additions and 3 deletions

View File

@ -24,6 +24,9 @@
(extfl<= (extflabs (fl- fl1 fl2))
(real->extfl 1e-8)))
(test (/ 23318339437 (expt 2 16443)) extfl->exact 3.4t-4940)
(test 3.40000000000116185t-4940 real->extfl (extfl->exact 3.40000000000116185t-4940))
;; in-extflvector tests.
(let ((flv (extflvector 1.0t0 2.0t0 3.0t0)))
(let ((flv-seq (in-extflvector flv)))

View File

@ -2926,6 +2926,10 @@
(test (expt 2 256) inexact->exact 1.157920892373162d+77)
(test 115792089237316195423570985008687907853269984665640564039457584007913129639936 inexact->exact 1.157920892373162d+77)
(test 521335/89202980794122492566142873090593446023921664 inexact->exact 5.844367f-39)
(test 5.844367f-39 real->single-flonum (inexact->exact 5.844367f-39))
(test (real->double-flonum 5.844367f-39) exact->inexact (inexact->exact 5.844367f-39))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(test (integer-bytes->integer #"\1\2" #f) integer-bytes->integer #"\1\2" #f (system-big-endian?))
@ -3374,7 +3378,7 @@
(random (expt 2 28)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check roun-to-even of rationale conversion (thanks to Robby)
;; Check round-to-even of rational conversion (thanks to Robby)
(let ()
(define l (floating-point-bytes->real #"\x1a\xd8\x9c\x17\x21\x2e\xfd\x25" #t))

View File

@ -566,7 +566,7 @@ Scheme_Object *scheme_rational_sqrt(const Scheme_Object *o)
#define SCHEME_CHECK_FLOAT scheme_check_float
#define SCHEME_BIGNUM_FROM_FLOAT scheme_bignum_from_float
#define DO_FLOAT_DIV scheme__do_float_div
#define FLOAT_E_MIN (-127)
#define FLOAT_E_MIN (-149)
#define FLOAT_M_BITS 23
#define FLOAT_E_BITS 8
#include "ratfloat.inc"
@ -592,7 +592,7 @@ Scheme_Object *scheme_rational_sqrt(const Scheme_Object *o)
# define SCHEME_BIGNUM_TO_FLOAT_INF_INFO scheme_bignum_to_long_double_inf_info
# define SCHEME_CHECK_FLOAT scheme_check_long_double
# define SCHEME_BIGNUM_FROM_FLOAT scheme_bignum_from_long_double
# define FLOAT_E_MIN (-16383)
# define FLOAT_E_MIN (-16445)
# define FLOAT_M_BITS 64
# define FLOAT_E_BITS 15
# define FP_ZEROx get_long_double_zero()