Wrong result with enum
Salih Dincer
salihdb at hotmail.com
Thu Nov 11 09:11:37 UTC 2021
On Thursday, 11 November 2021 at 06:34:16 UTC, Stanislav Blinov
wrote:
> On Thursday, 11 November 2021 at 05:37:05 UTC, Salih Dincer
> wrote:
>> is this a issue, do you need to case?
>>
>> ```d
>> enum tLimit = 10_000; // (1) true result
>> enum wLimit = 100_000; // (2) wrong result
>> ```
>
> https://dlang.org/spec/enum.html#named_enums
>
> Unless explicitly set, default type is int. 10000100000 is
> greater than int.max.
100001
```d
enum w = 100_000;
size_t b = w * w;
// size_t b = 100000 * 100000; // ???
assert(b == 10_000_000_000); // Assert Failure
```
The w!(int) is not greater than the b!(size_t)...
More information about the Digitalmars-d-learn
mailing list