abs and minimum values

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Oct 29 15:52:21 UTC 2021


On Thursday, 28 October 2021 at 21:23:15 UTC, kyle wrote:
> I stumbled into this fun today. I understand why abs yields a 
> negative value here with overflow and no promotion. I just want 
> to know if it should. Should abs ever return a negative number? 
> Thanks.

D has defined signed integers to be modular, so it represent 
numbers mapped to a circle rather than a line.

Is that a good idea? No, but that is what you have.





More information about the Digitalmars-d-learn mailing list