Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to round up float to integer

Tags:

haskell

I have a float 1.23 for instance, if I use round, it returns 1. My desired output is 2, which is round to the next integer. I can write a function to do it. I just wonder is there any already written function to do it (like round). Thanks.

like image 621
Tri Nguyen Avatar asked Nov 12 '16 06:11

Tri Nguyen


Video Answer


1 Answers

You can use the ceiling function (in Prelude):

ghci>> ceiling 1.23
2
like image 53
mnoronha Avatar answered Oct 08 '22 05:10

mnoronha