Integer literals

ric maicle via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 4 07:33:15 PST 2016


On Monday, 04 January, 2016 10:58 PM, Adam D. Ruppe wrote:
> On Monday, 4 January 2016 at 14:54:29 UTC, ric maicle wrote:
>>   0U .. 4_294_967_296U
>>
>> in the table Decimal Literal Types has a typo. Shouldn't the range
>> end with 4_294_967_295U?
>
> The x .. y syntax excludes y. So 0..3 covers 0, 1, 2. It excludes 3.

I copied part of the table here:

             0   .. 2_147_483_647
2_147_483_648   .. 9_223_372_036_854_775_807
             0L  .. 9_223_372_036_854_775_807L
             0U  .. 4_294_967_296U
4_294_967_296U  .. 18_446_744_073_709_551_615U
             0UL .. 18_446_744_073_709_551_615UL

If the range is x to y-1 shouldn't the rest of the other ending ranges
also be one greater than the maximum value of their types?


More information about the Digitalmars-d-learn mailing list