Operator declaration

Nick Treleaven nick at geany.org
Mon Jun 1 08:40:49 UTC 2026


On Sunday, 31 May 2026 at 23:53:27 UTC, Dom Disc wrote:
> -byte.min == byte.min (twos complement - also the same result 
> as if the int-value 128 is truncated to signed eight bit), so 
> yes, this should be allowed.

You are talking about bit patterns. VRP is to determine a number 
range.

-byte.min = 128
byte.min = -128

VRP correctly sees that those two values are not the same.

>  -x should always have same type as x.

Not necessarily, doing that is more bug-prone.

> But I would prefer that T.min is NaN of signed types. Instead 
> byte.min should be -127 (or general T.min == -T.max). This 
> would also fix abs().

The hardware does not treat T.min as NaN, so that is a no-go.


More information about the Digitalmars-d-learn mailing list