comp.lang.ada
 help / color / mirror / Atom feed
From: Tom_Hargraves@Raytheon.com
To: comp.lang.ada@ada.eu.org
Subject: Unsigned Longword
Date: 1999/12/10
Date: 1999-12-10T22:56:48+00:00	[thread overview]
Message-ID: <OF8A70EE05.EDBCEFED-ON88256843.0079C931@ray.ca> (raw)



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.









             reply	other threads:[~1999-12-10  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-10  0:00 Tom_Hargraves [this message]
1999-12-10  0:00 ` Unsigned Longword Jeff Creem
1999-12-10  0:00 ` Matthew Heaney
1999-12-11  0:00 ` Ed Falis
replies disabled

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