From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,245c84afd1e393ce X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: What about big integers in Ada 2005? Date: 30 Sep 2005 13:41:52 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1581461.uQ1jN63t33@linux1.krischik.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1128102112 5947 192.74.137.71 (30 Sep 2005 17:41:52 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 30 Sep 2005 17:41:52 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5313 Date: 2005-09-30T13:41:52-04:00 List-Id: writes: > "Martin Krischik" wrote in message > news:1581461.uQ1jN63t33@linux1.krischik.com... > > jtg wrote: > > > > > When I started to learn Ada, one of the most interesting features for me > > > was the possibility to declare integer type of the specified range. > > > I imagined that the integer type may be of any size. > > > However, several years later I needed big integers and I was > > > disappointed - Ada95 does not support integers of ANY size, > > > it can support only those integers that are supported > > > by the processor, or smaller. > > > > You are mistaken here. i.E GNAT supports 64 integers for 32 bit CPUs. It's > > all up to the particular compiler. In theory you could create an Ada > > compiler which supports intergers up to the memory limit - it would still > > conform to the standart. I'm not sure that would work very well. Programmers today often write things like "range 0..System.Max_Int", which wouldn't work well if Max_Int requires something like 2**36 bits to store. That is, programmers sometimes _rely_ on the fact that Ada compilers limit integers to a small number of machine words (like one or two). Anyway, it's not very interesting when compilers are _allowed_ to provide some capability. The interesting features (to me) are the ones that I can count on existing in _every_ compiler -- because I usually want to write portable code. > 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)". > Richard Riehle - Bob