BusFactor1 / mcl

Automatically exported from code.google.com/p/mcl
Other
1 stars 0 forks source link

expt dependence on *read-default-float-format* #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
From info-mcl September 17, 2009 11:01:00 AM PDT:

apparent bug in MCL/RMCL  
implementation of expt?

;; problem: dependence of expt on *read-default-float-format*
;; MCL -- causes inappropriate error when *read-default-float-format*  
should not matter
;; RMCL -- crashes the application

(setq *read-default-float-format* 'double-float)

;; appropriate error -- floating point overflow
(null (expt 2.0e7 2.0e7))
Error: FLOATING-POINT-OVERFLOW detected
       performing EXPT on (2.0D+7 2.0D+7)

;; no error
(null (expt 2.0e7 6.0))

(setq *read-default-float-format* 'short-float)

;; appropriate error -- floating point overflow
(null (expt 2.0e7 2.0e7))
Error: FLOATING-POINT-OVERFLOW detected
       performing EXPT on (2.0D+7 2.0D+7)

;; inappropriate error in MCL, crashes RMCL
;; nobody asked for type coercion to short-float!!!!
(null (expt 2.0e7 6.0))
Error: Can't coerce 6.4D+43 to SHORT-FLOAT
While executing: CCL::%DOUBLE-FLOAT->SHORT-FLOAT

--------------

*read-default-float-format* is relevant here:

"Controls the floating-point format that is to be used when reading a  
floating-point number that has noexponent marker or that has e or E  
for an exponent marker."

So 2.0e7 is a double-float if *read-default-float-format* is double- 
float.

The RMCL crash is definitely a bug. I'm not sure why regular MCL is  
working with double-floats when you set *read-default-float-format* to  
short-float.

Original issue reported on code.google.com by terje.norderhaug on 20 Sep 2009 at 6:39