easy question: transform Float -> Int how?

If I have a value of type Float, and I want to pass it (approximately rounded) to a function wanting an Int, how do I do that?

Use the round function (or ceiling or floor).
On Fri, Apr 25, 2014 at 10:56 AM, John M. Dlugosz
If I have a value of type Float, and I want to pass it (approximately rounded) to a function wanting an Int, how do I do that?
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Hi John,
This page http://www.haskell.org/haskellwiki/Converting_numbers should
have you covered. Check section 3 especially.
Thanks,
Arjun
On Fri, Apr 25, 2014 at 10:56 AM, John M. Dlugosz
If I have a value of type Float, and I want to pass it (approximately rounded) to a function wanting an Int, how do I do that?
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 4/25/2014 10:03 AM, Arjun Comar wrote:
Hi John,
This page http://www.haskell.org/haskellwiki/Converting_numbers should have you covered. Check section 3 especially.
Very nice—thanks for the link. David: I must have overlooked round,truncate,ceiling. I think I didn't realize that they don't return the same type that they take as argument. Anyway, "round" worked. Thanks!
participants (3)
-
Arjun Comar
-
David McBride
-
John M. Dlugosz