change `floating-point-bytes->real' to always produce a flonum
This commit is contained in:
parent
ff0a591b7b
commit
dfa36afa89
|
@ -937,7 +937,7 @@ of length @racket[size-n], the @exnraise[exn:fail:contract].}
|
||||||
[big-endian? any/c (system-big-endian?)]
|
[big-endian? any/c (system-big-endian?)]
|
||||||
[start exact-nonnegative-integer? 0]
|
[start exact-nonnegative-integer? 0]
|
||||||
[end exact-nonnegative-integer? (bytes-length bstr)])
|
[end exact-nonnegative-integer? (bytes-length bstr)])
|
||||||
(and/c real? inexact?)]{
|
flonum?]{
|
||||||
|
|
||||||
Converts the IEEE floating-point number encoded in @racket[bstr] from
|
Converts the IEEE floating-point number encoded in @racket[bstr] from
|
||||||
position @racket[start] (inclusive) to @racket[end] (exclusive) to an
|
position @racket[start] (inclusive) to @racket[end] (exclusive) to an
|
||||||
|
|
|
@ -2750,8 +2750,8 @@
|
||||||
(< a -1e38))))
|
(< a -1e38))))
|
||||||
|
|
||||||
(map (lambda (n)
|
(map (lambda (n)
|
||||||
(test #t close? (real->single-flonum n) (floating-point-bytes->real (real->floating-point-bytes n 4 #t) #t))
|
(test #t close? n (floating-point-bytes->real (real->floating-point-bytes n 4 #t) #t))
|
||||||
(test #t close? (real->single-flonum n) (floating-point-bytes->real (real->floating-point-bytes n 4 #f) #f))
|
(test #t close? n (floating-point-bytes->real (real->floating-point-bytes n 4 #f) #f))
|
||||||
(test n floating-point-bytes->real (real->floating-point-bytes n 8 #t) #t)
|
(test n floating-point-bytes->real (real->floating-point-bytes n 8 #t) #t)
|
||||||
(test n floating-point-bytes->real (real->floating-point-bytes n 8 #f) #f))
|
(test n floating-point-bytes->real (real->floating-point-bytes n 8 #f) #f))
|
||||||
(append
|
(append
|
||||||
|
|
|
@ -2090,7 +2090,7 @@ static Scheme_Object *bytes_to_real (int argc, Scheme_Object *argv[])
|
||||||
{
|
{
|
||||||
float f;
|
float f;
|
||||||
memcpy(&f, buf, sizeof(float));
|
memcpy(&f, buf, sizeof(float));
|
||||||
#ifdef MZ_USE_SINGLE_FLOATS
|
#ifdef MZ_USE_SINGLE_FLOATS_AS_DEFAULT
|
||||||
return scheme_make_float(f);
|
return scheme_make_float(f);
|
||||||
#else
|
#else
|
||||||
return scheme_make_double(f);
|
return scheme_make_double(f);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user