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
-}
This entry was posted
on Tuesday, May 15th, 2007 at 5:25 pm and is filed under Haskell - SOE.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.