Wrong result with enum
Tejas
notrealemail at gmail.com
Thu Nov 11 12:05:19 UTC 2021
On Thursday, 11 November 2021 at 09:11:37 UTC, Salih Dincer wrote:
> 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)...
Are you on 32-bit OS? I believe `size_t` is 32 bits on 32 bit OS
and 64 on a 64-bit OS
More information about the Digitalmars-d-learn
mailing list