comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: 64 bit integer support as native type
Date: 23 Sep 1994 16:09:15 GMT
Date: 1994-09-23T16:09:15+00:00	[thread overview]
Message-ID: <35uujb$185r@watnews1.watson.ibm.com> (raw)
In-Reply-To: 35setv$7nq@walters.East.Sun.COM

In article <35setv$7nq@walters.East.Sun.COM>, brent@paisley.East.Sun.COM
(Brent Slone) writes: 

|> Does the Ada LRM define a 64 bit integer?

No, but then again, it wouldn't.  Implementations, not the LRM, define
the ranges of integer types they support.

|>                                            If not, what is the most
|> straightforward method for implementing 64 bit ints?

A programmer can declare an integer type with the range of conventional
64-bit twos complement as follows: 

   type Integer_64 is range -2**63 .. 2**63-1;

One of three things may happen as a result of this declaration: 

   o You may get object code that efficiently exploits the 64-bit
     registers of your target machine.

   o You may get code that performs 64-bit arithmetic in software, for
     example storing an Integer_64 value in a pair of registers and
     turning an addition into an add-setting-carry-bit instruction for
     the low-order registers in each pair, followed by an
     add-two-registers-plus-carry-bit instruction for the high-order
     registers in each pair.

   o You may get an error message stating that your compiler does not
     support integer types with so large a range.

In any event, you are guaranteed that if the compiler accepts the
declaration, the type will support the semantics of 64-bit 2's-complement
integers.

(I can already hear Robert Dewar saying, "There you go again, Norman!"
His displeasure with defining types in terms of presumed
hardware constraints rather than the ranges of values needed to solve the
problem at hand is certainly valid, but you posed a requirement for
64-bit integers, so I'm assuming that that is your application's
requirement.  Since just about all machines not manufactured in Minnesota
have word sizes of 16, 32, or 64 bytes, and since some programs have a
need to deal with hardware, hardware-inspired file formats, or interfaces
to other software, it is not all that unreasonable for "64-bit integer"
to arise as an abstract software requirement.)

--
Norman H. Cohen    ncohen@watson.ibm.com



  parent reply	other threads:[~1994-09-23 16:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-22 17:29 64 bit integer support as native type Brent Slone
1994-09-23 11:55 ` Robert I. Eachus
1994-09-23 15:34 ` Robert Dewar
1994-09-23 16:09 ` Norman H. Cohen [this message]
     [not found] <35setv$7nq@walters.east.sun.com>
1994-09-23 17:41 ` Tucker Taft
replies disabled

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