[Haskell-cafe] Please explain behavior of setBit
Murray Gross
mgross21 at verizon.net
Sun Nov 13 00:08:36 EST 2005
Here is my trivial program:
import Bits
main = putStr (show(bit 0::Int)++" "++show (mybit 0))
mybit:: Int -> Int
mybit x = setBit (bit 0) x
The output (with GHC-5) is
1 1
My question: Why is (bit 0) equal to 1 and not 0? That first bit is set
regardless of the value of x (I have tried several), although in each
case, the bit I expect to be set is also set (e.g., mybit 4 yields 17).
Thanks in advance for assistance.
Murray Gross
More information about the Haskell-Cafe
mailing list