[Haskell-cafe] Difference between div and /

Daniel Fischer daniel.is.fischer at web.de
Tue Jun 1 17:15:26 EDT 2010


On Tuesday 01 June 2010 22:40:51, Jonas Almström Duregård wrote:
> >> One might expect a == (a/b)*b and other common arithmetic formulas to
> >> hold for division?
> >
> > Better not if one's using Float or Double.
>
> I figured someone would say that :)

*g*

>
> What about this one:
> round (a/b/c) == round (a/(b*c))

Don't know, we have
(a `quot` b) `quot` c == a `quot` (b*c)
for Integers (overflow may or may not break that for Int), so if (/) were 
truncating division for Integral types, we'd have that.

I like the distinction between (/) and div (and quot), but I have no 
problem using (/) for integer division in Python, C, Java or C#.

>
> Of course this doesn't work on Integers...
>
> /J
>
> On 1 June 2010 21:08, Daniel Fischer <daniel.is.fischer at web.de> wrote:
> > On Tuesday 01 June 2010 20:26:55, Jonas Almström Duregård wrote:
> >> One might expect a == (a/b)*b and other common arithmetic formulas to
> >> hold for division?
> >>
> >> /Jonas
> >
> > Better not if one's using Float or Double.



More information about the Haskell-Cafe mailing list