Oh Dear

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Sun Jul 12 03:29:42 PDT 2009


Rainer Deyke wrote:

> Actually I suspect that integer division with negative values is rare
> enough that a problem might escape notice for some time.

Yep. It's possible. I suggest someone tests this. I don't have a D compiler
installed, and I don't really have time for this.

> floor division, which is 99% of the time the type of division I want.

Agreed. I'm using floored division in my new programming language. The
quotient rounds towards negative infinity and the result of the mod
operation has the same sign as the divisor.

However, it seems D prides itself on its speed. And since truncated division
is implemented by the hardware, D will probably use that. And that's
acceptable, as long as it's guaranteed (predictable).

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list