[Openmcl-devel] Error in rational -> float conversion

Ron Garret ron at flownet.com
Mon Sep 20 11:40:48 PDT 2021


On Sep 20, 2021, at 10:42 AM, Raymond Wiker <rwiker at gmail.com> wrote:

> Does it make a difference if you correct the misspelling of double-float?
> 
>> On 20 Sep 2021, at 19:28 , Ron Garret <ron at flownet.com> wrote:
>> 
>>                        (/ (the doble-float (coerce (numerator x) 'double-float))
>> 
> 

Nope:

? (time (dotimes (i 1000000)
        (let ((x (/ (random 1000000000000) (random 1000000000000))))
          (coerce (the double-float
                       (/ (the double-float (coerce (numerator x) 'double-float))
                          (the double-float (coerce (denominator x) 'double-float))))
                  'single-float))))
(DOTIMES (I 1000000) (LET ((X (/ (RANDOM 1000000000000) (RANDOM 1000000000000)))) (COERCE (THE DOUBLE-FLOAT (/ (THE DOUBLE-FLOAT (COERCE (NUMERATOR X) 'DOUBLE-FLOAT)) (THE DOUBLE-FLOAT (COERCE (DENOMINATOR X) 'DOUBLE-FLOAT)))) 'SINGLE-FLOAT)))
took 543,342 microseconds (0.543342 seconds) to run.
       8,019 microseconds (0.008019 seconds, 1.48%) of which was spent in GC.
During that period, and with 4 available CPU cores,
     536,305 microseconds (0.536305 seconds) were spent in user mode
      10,985 microseconds (0.010985 seconds) were spent in system mode
 64,000,000 bytes of memory allocated.
 180 minor page faults, 0 major page faults, 0 swaps.
NIL
? 

(I would not have expected this to make a difference.  A correct type declaration is very unlikely to slow things down.)

rg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20210920/c1e583ac/attachment.htm>


More information about the Openmcl-devel mailing list