Oh Dear

Daniel Keep daniel.keep.lists at gmail.com
Sun Jul 12 07:34:42 PDT 2009



Michiel Helvensteijn wrote:
> 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).

My personal bug-bear is that D inherited C's insane % behaviour.  I had
this cause a really horrible bug in my simulator where if you set the
virtual date to before the epoch (which you would do in the course of
simulating historical events), the scheduling system went completely
bananas.

Took ages to find that one because I'd been testing dates post-epoch.



More information about the Digitalmars-d mailing list