SOE ex.4.1


inchToPixel :: Float -> Int
inchToPixel x = round (100 * x)

inchToPixel' :: Float -> Int
inchToPixel' x = 100 * round x

{-
Answer: Because of lost precision.

"round" rounds a float value to integer.

Some examples:
inchToPixel 1.234 = 123
inchToPixel 1.235 = 124
inchToPixel' 1.234 = 100
inchToPixel' 1.235 = 100
-}

Leave a Reply