Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 03, 2014 integer out of range | ||||
---|---|---|---|---|
| ||||
why is this possible? int count = 50_000_000; |
July 03, 2014 Re: integer out of range | ||||
---|---|---|---|---|
| ||||
Posted in reply to pgtkda | On Thursday, 3 July 2014 at 10:15:25 UTC, pgtkda wrote:
> why is this possible?
>
> int count = 50_000_000;
int is always 4 bytes, it can contains from -2_147_483_648 to 2_147_483_647.
|
July 03, 2014 Re: integer out of range | ||||
---|---|---|---|---|
| ||||
Posted in reply to ponce | On Thursday, 3 July 2014 at 10:22:14 UTC, ponce wrote:
> On Thursday, 3 July 2014 at 10:15:25 UTC, pgtkda wrote:
>> why is this possible?
>>
>> int count = 50_000_000;
>
> int is always 4 bytes, it can contains from -2_147_483_648 to 2_147_483_647.
oh, ok. I thought it only contains numbers to 2_000_000, but 2 to the power of 32 is your result, thanks.
|
July 03, 2014 Re: integer out of range | ||||
---|---|---|---|---|
| ||||
Posted in reply to pgtkda | On Thu, 03 Jul 2014 10:24:26 +0000 pgtkda via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > On Thursday, 3 July 2014 at 10:22:14 UTC, ponce wrote: > > On Thursday, 3 July 2014 at 10:15:25 UTC, pgtkda wrote: > >> why is this possible? > >> > >> int count = 50_000_000; > > > > int is always 4 bytes, it can contains from -2_147_483_648 to 2_147_483_647. > > oh, ok. I thought it only contains numbers to 2_000_000, but 2 to the power of 32 is your result, thanks. If you want to know the min and max of the numeric types, just use their min and max properties - e.g. int.min or long.max. - Jonathan M Davis |
Copyright © 1999-2021 by the D Language Foundation