chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Numbers weirdness


From: Peter Bex
Subject: Re: [Chicken-users] Numbers weirdness
Date: Fri, 1 Apr 2016 18:51:16 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Fri, Apr 01, 2016 at 05:25:44PM +0100, Andy Bennett wrote:
> Hi,
> 
> In CHICKEN 4.9.0rc1 and 4.10.0 both with numbers 4.6:
> 
> -----
> #;1> (use numbers)
> #;2> (define (log2 n) (/ (log n) (log 2)))
> #;3> (= (log2 (expt 2 252)) (ceiling (log2 (expt 2 252))))
> #t
> #;4> (= (log2 (expt 2 251)) (ceiling (log2 (expt 2 251))))
> #f
> #;5> (log2 (expt 2 251))
> 251.0
> #;6> (ceiling (log2 (expt 2 251)))
> 252.0
> -----
> 
> 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

Cheers,
Peter

Attachment: signature.asc
Description: Digital signature


reply via email to

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