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

Ron Garret ron at flownet.com
Sun Sep 19 08:16:25 PDT 2021


Double-float version works for me:

? (lisp-implementation-version)
"Version 1.11-r16812M  (DarwinX8664)"
? (coerce 41107100000541273/100000000000 'double-float)
411071.00000541273D0

But there is definitely something hinky going on with converting to single-float:

? (float 411071000005/100000000000)
4.11071
? (float 411071000006/100000000000)
4.11071
? (float 4110710000055/100000000000)
41.107098


On Sep 19, 2021, at 6:05 AM, Steven Nunez <steve_nunez at yahoo.com> wrote:

> Hi folks,
> 
> I just posted an issue regarding what looks like a bug in rational->float conversion, and I'm hoping someone here can try this on 1.12 (preferably on MS Windows), or perhaps provide some insight as to what might be going on here for a quick fix.
> 
> CL-USER> (lisp-implementation-version)
> "Version 1.11.8 (v1.11.8-2-gd411e378) WindowsX8664"
> CL-USER> (float 41107100000541273/100000000000)
> 411071.03
> 
> Hmm. If you work out the decimal points, the float is: 411071.00000541273, that's a long way from .03. Maybe coerce? Nope, that's even worse:
> 
> CL-USER> (coerce 41107100000541273/100000000000 'double-float)
> 411071.03125D0
> 
> Any ideas? That's not a small rounding error.
> 
> Regards,
>     Steve
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel

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


More information about the Openmcl-devel mailing list