Bug in ^^

Brett Brett at gmail.com
Tue Sep 17 16:50:25 UTC 2019


On Tuesday, 17 September 2019 at 13:59:54 UTC, jmh530 wrote:
> On Tuesday, 17 September 2019 at 13:48:02 UTC, Brett wrote:
>> [snip]
>>
>>
>> Um, duh, but the problem why are they ints?
>> [snip]
>
> They are ints because that is how enums work in the D language. 
> See 17.3 [1].
>
> [1] https://dlang.org/spec/enum.html#named_enums

Then why does

>> enum x = 100000000000000000;
>> enum y = 10^^17;

x store 10000000000000000?

If it were an int then it would wrap, it doesn't.

Did you try the code?

import std.stdio;
enum x = 100000000000000000;
enum y = 10^^17;

void main()
{
     ulong xx = x;
     ulong yy = y;
     writeln(x);
     writeln(y);
     writeln(xx);
     writeln(yy);
}

100000000000000000
1569325056
100000000000000000
1569325056

You seem to either make stuff up, misunderstand the compiler, or 
trust the docs to much. I have code that proves I'm right, why is 
it so hard for you to accept it?

You can make your claims, but it is meaningless if they are not 
true.



More information about the Digitalmars-d mailing list