Assert(min(int) + max(int) == -1)

Does this hold true for all known hardware on which Chapel runs?

Thanks

Hi Damian —

I would expect so since the values are well-defined and computing their sum doesn't involve overflow/wraparound. Does something specific make you worry it might not?

-Brad

No. But I always worry about architecture assumptions. And my brain was functioning in late-night mode so I was just checking it not gone into sleep mode in advance of the rest of the body. Thanks for the confirmation.

I use that assumption in a case where overflow is possible but I think I have it covered. I want the absolute value of an int (as a uint),

assert(a.type == int);
...
param M = max(int)
param m = min(int);
var abs_a = if a == m then 1:uint + M:uint else abs(a):uint