abs and minimum values
kyle
kbcomm at protonmail.com
Thu Oct 28 21:23:15 UTC 2021
```
void main()
{
import std.math : abs, sgn;
alias n_type = short; //or int, long, byte, whatever
assert(n_type.min == abs(n_type.min));
assert(sgn(abs(n_type.min)) == -1);
}
```
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.
More information about the Digitalmars-d-learn
mailing list