News for hackers. Stuff that matters.
Re:Don't distract new programmers with OOP by IvarTJ on Friday March 18, 2011 @04:03AM (#2339750)
I sometimes want to avoid using floats because of the inaccuracy that sometimes arise with their use. If I recall correctly, in Haskell division requires the numerator and denominator to be of the class fractional. So how I did integer division was something like this

round (fromIntegral x / fromIntegral y)

round is one of several functions that transform numbers to integers.

Re:Don't distract new programmers with OOP by sid0 on Friday March 18, 2011 @04:51AM (#2339811)

    Prelude> 5 `div` 2
    2
Haskell's doing the right thing here by having a separate function for integer division. It makes no sense to overload / to mean both regular and integer division.