On 1/24/2014 1:39 PM, Dominikus Dittes Scherkl wrote:
On Friday, 24 January 2014 at 19:03:59 UTC, Walter Bright wrote:
On 1/24/2014 2:40 AM, Dominikus Dittes Scherkl wrote:
Ah, ok. Of course the small types always become int.
But the problem would be the same with
long a = long.min;
auto b = -a;
does this return ulong (which could hold the correct result) or long (and a
wrong result)?
The negation operator does not change the type, and no operation changes the
type as the result of particular runtime operand values.
So, was Andrei wrong as he claimed b would be "int" in my first example?
No.
1. a was promoted to int before the negation operator was applied.
2. types do not depend on particular runtime values (the whole notion of static
typing would fall apart if it did)