chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Numbers weirdness


From: Andy Bennett
Subject: Re: [Chicken-users] Numbers weirdness
Date: Fri, 1 Apr 2016 18:23:28 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0

Hi,

>> Is it just late on a Friday? Am I crazy?
> 
> Floating point numbers are weird enough to drive anyone bat shit:
> 
> #;1> (use numbers)
> #;2> (define (log2 n) (/ (log n) (log 2)))
> #;3> (log2 (expt 2 251))
> 251.0
> #;4> (flonum-print-precision 100)
> 15
> #;5> (log2 (expt 2 251))
> 251.000000000000028421709430404007434844970703125

Thanks Peter!

I'm mostly using log2 to work out if numbers are a power of two and find
the highest bit that they have set.

Is there a more robust way to do that in CHICKEN when using the numbers
egg and bignums?






Regards,
@ndy

-- 
address@hidden
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]