truncate/floor with logBase

Thorsten Stocksmeier thorsten.stocksmeier@t-online.de
Sat, 28 Sep 2002 09:35:41 +0200


Hello,

consider the following:

Main> :version
-- Hugs Version February 2001
Main> logBase 2 (fromInteger 32768)  -- compute ld 2^15
15.0
Main> truncate 15.0
15
Main> floor 15.0
15
Main> floor (logBase 2 (fromInteger 32768))    -- should be == floor 15.0
14
Main> truncate (logBase 2 (fromInteger 32768)) -- should be == truncate 15.0
14

I can reproduce this with 8192 and 32768.

To cut it short: (truncate (logBase 2 (fromInteger 2^a))) != a ; a=13 & a=15

Looks a little weird to me, but I'm a Haskell beginner, so
possibly I just encountered an "It's not a bug, it's a feature"
situation here. Sorry if this is the case.

Thanks in advance,
Thorsten Stocksmeier