comp.lang.ada
 help / color / mirror / Atom feed
From: <adaworks@sbcglobal.net>
Subject: Re: What about big integers in Ada 2005?
Date: Sun, 02 Oct 2005 00:27:05 GMT
Date: 2005-10-02T00:27:05+00:00	[thread overview]
Message-ID: <tPF%e.2030$lc1.608@newssvr21.news.prodigy.com> (raw)
In-Reply-To: wccmzlu3127.fsf@shell01.TheWorld.com


"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
news:wccmzlu3127.fsf@shell01.TheWorld.com...
> <adaworks@sbcglobal.net> writes:
>
>
> > I interepreted this question to refer to integers of arbitrary size such as
> > those in Smalltalk.   In Ada compilers, as with other language with
> > implementations tied to the underlying platrform, numbers are related
> > to the word size of the targeted machine.    For example, I cannot define,
> > on any Ada compiler that I know of, an Integer such as,
> >
> >        type Number is range 0..2**78;
> >
> > since this would overflow contemporary (not future) architectures.  In
> > Smalltalk,
> > and many other languages, we can do arithmetic on numbers such as,
> >
> >         34567345754784567745464478456345356675
> > and
> >         99874257918340987932560129346591237523
> >
> > Of course, this is not an inherent limitation of Ada.  One can create a
package
> > to do this kind of arithmetic, but it is not all that easy to do so.
>
> One annoying thing is that every Ada compiler must implement such a
> package, yet this package is not (portably) available to Ada
> programmers.  Some such package has to exist in every implementation,
> because static expressions are evaluated with arbitrarily-large range at
> compile time.  But that functionality is not (standardly) available at
> run time.  Sigh.
>
> The other annoying thing is that even if you have such a package, you
> have to use different (uglier) notations for various things (literals,
> case statements, range constraints, etc).  So if I want an integer range
> 1..2**40, say, should I use an arbitrary-range arithmetic package and
> write ugly-but-portable code?  Or should I take advantage of a
> particular Ada compiler that supports it?  Neither choice is good.
>
> I happen to think "range 0..2**78" should be required of all Ada
> implementations.  Or even "0..2**(2**12)".
>
I am glad to see that we agree on this Bob.   One of the key ideas of
abstraction is that we are not limited to the underlying architecture of
the hardware but can use that architecture in more creative ways.

COBOL solved this problem years ago with its capability for variable
length numbers via the PICTURE clause.   Smalltalk, mentioned in
my earlier post is particularly good at this kind of thing.    One would
think that Ada, with its emphasis on building good abstractions, would
have support for it.

Richard Riehle





  parent reply	other threads:[~2005-10-02  0:27 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-15 17:06 What about big integers in Ada 2005? jtg
2005-09-15 17:26 ` Pascal Obry
2005-09-15 17:30   ` Martin Dowie
2005-09-15 17:26 ` Martin Krischik
2005-09-15 19:37   ` Martin Dowie
2005-09-15 21:08     ` Larry Kilgallen
2005-09-15 20:33   ` jtg
2005-09-15 21:10     ` Larry Kilgallen
2005-09-18  0:46   ` adaworks
2005-09-30 17:41     ` Robert A Duff
2005-09-30 20:18       ` Jeffrey R. Carter
2005-10-02  0:27       ` adaworks [this message]
     [not found]         ` <imsuj1h8vevg4un71rmh0nc41pnee5ihjl@4ax.com>
2005-10-02 10:33           ` Martin Krischik
2005-10-02 16:20             ` adaworks
2005-10-04  5:24           ` adaworks
2005-10-04  7:22             ` tmoran
2005-10-04  8:25             ` Dmitry A. Kazakov
2005-10-04 11:57               ` Simon Clubley
2005-10-04 16:10                 ` Robert A Duff
2005-10-04 17:24                   ` Simon Clubley
2005-10-04 19:44                     ` Robert A Duff
2005-10-04 13:46               ` adaworks
2005-10-04 16:38                 ` Robert A Duff
2005-10-04 16:52                   ` Martin Dowie
2005-10-04 17:16                     ` Robert A Duff
2005-10-04 13:50               ` adaworks
2005-10-04 14:59                 ` Larry Kilgallen
2005-10-04 16:03                 ` Robert A Duff
2005-10-04 18:56                   ` adaworks
2005-10-10  5:36                     ` Dave Thompson
2005-10-14  0:31                       ` adaworks
2005-10-06 14:21             ` Adrian Hoe
2005-10-07  6:48               ` Martin Krischik
2005-10-02  0:48   ` Brian May
2005-10-02 10:28     ` Martin Krischik
2005-10-02 10:52       ` Brian May
2005-10-02 15:12       ` Simon Wright
2005-10-02 17:11         ` Martin Dowie
2005-09-16 14:33 ` gautier_niouzes
2005-09-17  3:43   ` Craig Carey <research@ijs.co.nz>
replies disabled

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