if. , , "logBase (...)" "" (logBase (...)) ". Floating, Integral. ( ), , .
, , , , . :
powersOfTwo :: [Integer]
powersOfTwo = iterate (*2) 1
isPowerOfTwo x = xInt == head (dropWhile (<xInt) powersOfTwo)
where xInt = toInteger x
, , , , , "logBase 2". , , . , : truncate (logBase 2 512) == truncate (logBase 2 550) (Edit: , , , , , , , , , logBase 2 (...) - , , ).
source
share