comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: 64-bit unsigned integer?
Date: Mon, 26 Feb 2018 17:19:21 -0600
Date: 2018-02-26T17:19:21-06:00	[thread overview]
Message-ID: <p724lq$2na$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: a0147c10-775c-49bf-a0e7-2091f31ac11a@googlegroups.com

"MM" <mrvmurray@gmail.com> wrote in message 
news:a0147c10-775c-49bf-a0e7-2091f31ac11a@googlegroups.com...
> On Sunday, 25 February 2018 16:36:47 UTC, Anh Vo  wrote:
>> On Sunday, February 25, 2018 at 4:30:59 AM UTC-8, MM wrote:
>> > I tried
>> >
>> > type u64 is range 0 .. 2**64-1; -- this fails with "integer type 
>> > definition bounds out of range".
>> >
>>
>> It should be: type u64 is range 0 .. 2 **63 - 1;
>
> That is a 63-bit unsigned, no?
>
>> This is max that GNAT can support on 64 bit architecture.
>
> Apparently :-)

This is a language limitation. That's because U64'Base is always legal, and 
it has a symmetric signed range. Thus you need the signed values even if you 
never intent to use them.

>> > type u64 is range 0 .. 2**64-1; -- this fails with "integer type 
>> > definition bounds out of range".
>>
>> This is the right method alas not supported by the architecture of the
>> machine you have.
>
>Damn. Its a 64-bit CPU; I would have thought that a Carry Or Overflow
>bit in the processor would have done the trick?

There's not the least bit of difficulty supporting such a thing; the 
Janus/Ada code generator has the needed operations and code generation (for 
32-bit types, no 64-bit integers yet). I'd suspect that the same is true of 
many other code generators.

The problem is simply one of language definition; there is no way in the Ada 
language to get overflow for an unsigned type. Therefore, you can have 
overflow on unsigned representation only so long as there is a (larger) 
signed representation available. (For instance, an overflowing unsigned byte 
representation is fine, as it can use a 16-bit signed base type).

This limitation has always bothered me, but it never has been considered 
important enough to address in the language. These days, we're moving away 
from adding any more kinds of types; everything new will be a library much 
like the containers or the one Dmitry showed. (The reason being that we then 
don't need to define new kinds of generic types.) So I doubt the underlying 
issue will ever be changed.

                                         Randy.




  reply	other threads:[~2018-02-26 23:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-25 12:30 64-bit unsigned integer? MM
2018-02-25 12:41 ` Dmitry A. Kazakov
2018-02-25 12:54   ` MM
2018-02-25 13:23     ` Dmitry A. Kazakov
2018-02-25 13:59       ` MM
2018-02-25 14:20         ` Dmitry A. Kazakov
2018-02-25 15:34           ` MM
2018-02-25 16:35     ` Jeffrey R. Carter
2018-02-25 16:36 ` Anh Vo
2018-02-25 17:31   ` MM
2018-02-26 23:19     ` Randy Brukardt [this message]
2018-02-26 23:33       ` MM
2018-02-28 10:17       ` Paul Rubin
2018-02-28 10:39         ` J-P. Rosen
2018-02-28 10:59           ` Dmitry A. Kazakov
2018-02-28 23:20         ` Randy Brukardt
2018-03-01  5:47           ` Paul Rubin
2018-03-01  8:16             ` Niklas Holsti
2018-03-01  8:35               ` Simon Wright
2018-03-01  8:47               ` Dmitry A. Kazakov
2018-03-01 18:15                 ` Dan'l Miller
2018-03-01 19:10                   ` Dmitry A. Kazakov
2018-03-01 19:22                     ` Dan'l Miller
2018-03-01 19:59                       ` Dmitry A. Kazakov
2018-03-01 20:32                         ` Dan'l Miller
2018-03-01 21:15                           ` Dmitry A. Kazakov
2018-03-01 22:23                             ` Randy Brukardt
2018-03-01 23:50                             ` Robert Eachus
2018-03-01 20:06                     ` Niklas Holsti
2018-03-01 22:04               ` Randy Brukardt
2018-02-26  6:45 ` Robert Eachus
2018-02-27 16:40   ` Dan'l Miller
2018-02-27 17:18     ` J-P. Rosen
2018-02-27 18:17       ` Dan'l Miller
2018-02-28  3:03         ` Robert Eachus
2018-02-28  6:41         ` J-P. Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox