comp.lang.ada
 help / color / mirror / Atom feed
* Re: Unsigned Longword
  1999-12-10  0:00 Unsigned Longword Tom_Hargraves
@ 1999-12-10  0:00 ` Matthew Heaney
  1999-12-10  0:00 ` Jeff Creem
  1999-12-11  0:00 ` Ed Falis
  2 siblings, 0 replies; 4+ messages in thread
From: Matthew Heaney @ 1999-12-10  0:00 UTC (permalink / raw)


In article <OF8A70EE05.EDBCEFED-ON88256843.0079C931@ray.ca> , 
Tom_Hargraves@Raytheon.com  wrote:

> Anyway, at the time I really wanted a 'true' 32 bit 'Unsigned Longword'. One
> that went from 0..2**32-1, supported by associated +-/* operators. However, at
> the time, both of the compilers (DEC and VADS) had System packages which
> implemented unsigned longword as the Positive range of Integer, ie.
> 0..2**31-1. (An understandable implementation on a twos complement  machine).
> Thus a '+' arithmetic operation which caused a result whose MSB was set to '1'
> caused a constraint error.

VADS had a package called Unsigned_Types (or something like that) that
included true unsigned integers all the way up to and including 32 bits.
When you with'd that package, this turned on compiler magic, effectively
extending the language.


> I'd like to ask this forum if there was/is a nicer way of implementing a
> 'true' Unsigned Longword?

You could try suppressing overflow on the type:

  type Unsigned_Integer is new Integer;
  pragma Suppress (Overflow_Check, On => Unsigned_Integer);


--
The theory of evolution is quite rightly called the greatest unifying
theory in biology.  The diversity of organisms, similarities and
differences between kinds of organisms, patterns of distribution and
behavior, adaptation and interaction, all this was merely a bewildering
chaos of facts until given meaning by the evolutionary theory.

Populations, Species, and Evolution
Ernst Mayr




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Unsigned Longword
@ 1999-12-10  0:00 Tom_Hargraves
  1999-12-10  0:00 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom_Hargraves @ 1999-12-10  0:00 UTC (permalink / raw)
  To: comp.lang.ada



Please consider yourself in a 32 bit hardware architectural world for the
purposes of this query :-)

I remember a couple of years ago having to do bits-and-bytes transfers between
different endian processors via a VME shared memory area. Not something to be
undertaken lightly, whether in Ada or any other language...

Anyway, at the time I really wanted a 'true' 32 bit 'Unsigned Longword'. One
that went from 0..2**32-1, supported by associated +-/* operators. However, at
the time, both of the compilers (DEC and VADS) had System packages which
implemented unsigned longword as the Positive range of Integer, ie. 0..2**31-1.
(An understandable implementation on a twos complement  machine). Thus a '+'
arithmetic operation which caused a result whose MSB was set to '1' caused a
constraint error.

We tried various definitions of our own Unsigned_Longword, but soon succumbed
to the line of least resistance under the pressure of project timescales. Hence
we invented overloaded '+' functions that checked ranges, and privately used '
-' if an addition would cause max_int to be exceeded.

I'd like to ask this forum if there was/is a nicer way of implementing a 'true'
Unsigned Longword?

Yours curiously,
Tom H.









^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unsigned Longword
  1999-12-10  0:00 Unsigned Longword Tom_Hargraves
  1999-12-10  0:00 ` Matthew Heaney
@ 1999-12-10  0:00 ` Jeff Creem
  1999-12-11  0:00 ` Ed Falis
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Creem @ 1999-12-10  0:00 UTC (permalink / raw)


> Anyway, at the time I really wanted a 'true' 32 bit 'Unsigned Longword'.
One
> that went from 0..2**32-1, supported by associated +-/* operators.
However, at
> the time, both of the compilers (DEC and VADS) had System packages which
> implemented unsigned longword as the Positive range of Integer, ie.
0..2**31-1.
> (An understandable implementation on a twos complement  machine). Thus a
'+'
> arithmetic operation which caused a result whose MSB was set to '1' caused
a
> constraint error.
>
> We tried various definitions of our own Unsigned_Longword, but soon
succumbed
> to the line of least resistance under the pressure of project timescales.
Hence
> we invented overloaded '+' functions that checked ranges, and privately
used '
> -' if an addition would cause max_int to be exceeded.
>
> I'd like to ask this forum if there was/is a nicer way of implementing a
'true'
> Unsigned Longword?
>


As far as the "was"...Probably not..It was a sometimes very painful result
of many
Ada 83 implementations (and it was very reasonable to hide behind the LRM on
this
issue but it certainly would have been possible to have unsigned 32 bit
longs in a 32 bit HW environment in Ada 83 if
the compiler provided a soft > 32 bit integer.


As far as "is"..If you use Ada 95 use modular types.








^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unsigned Longword
  1999-12-10  0:00 Unsigned Longword Tom_Hargraves
  1999-12-10  0:00 ` Matthew Heaney
  1999-12-10  0:00 ` Jeff Creem
@ 1999-12-11  0:00 ` Ed Falis
  2 siblings, 0 replies; 4+ messages in thread
From: Ed Falis @ 1999-12-11  0:00 UTC (permalink / raw)


In article <OF8A70EE05.EDBCEFED-ON88256843.0079C931@ray.ca>,
  comp.lang.ada@ada.eu.org wrote:

.
>
> I'd like to ask this forum if there was/is a nicer way of implementing a 'true'
> Unsigned Longword?

Well, these days most compilers will support type Interfaces.Unsigned_32. 
Now the issue (for some) is Unsigned_64 ;-)

- Ed


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-12-11  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-10  0:00 Unsigned Longword Tom_Hargraves
1999-12-10  0:00 ` Matthew Heaney
1999-12-10  0:00 ` Jeff Creem
1999-12-11  0:00 ` Ed Falis

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