Friday 29 April 2016

Haskell: div vs /


Both /, div are used to perform division. Only difference is / performs floating-point division only, for integers division we can use div.

*Main> 10 / 9
1.1111111111111112
*Main> 
*Main> div 10 9
1
*Main> 10 `div` 9
1


You can use ‘/’ in prefix notation also by using parenthesis.
*Main> (/) 10 9
1.1111111111111112



Previous                                                 Next                                                 Home

No comments:

Post a Comment