Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"You know, we've won awards for this crap." -- David Letterman


devel / comp.lang.ada / Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

SubjectAuthor
* Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Michael Ferguson
+- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Mark Lorenzen
+* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?AdaMagica
|+- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?AdaMagica
|+* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?AdaMagica
||`- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Niklas Holsti
|`- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Simon Wright
+* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Luke A. Guest
|`* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Michael Ferguson
| +- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Ben Bacarisse
| +* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Niklas Holsti
| |`* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Michael Ferguson
| | `* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Niklas Holsti
| |  +* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Luke A. Guest
| |  |`- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Dmitry A. Kazakov
| |  `* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?AdaMagica
| |   `* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Niklas Holsti
| |    `- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Ben Bacarisse
| +* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Mark Lorenzen
| |`- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Niklas Holsti
| +- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Paul Rubin
| `- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Paul Rubin
`* Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?Jeffrey R.Carter
 `- Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?AdaMagica

1
Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6401&group=comp.lang.ada#6401

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:199a:: with SMTP id bm26mr1121844qkb.542.1640152629569;
Tue, 21 Dec 2021 21:57:09 -0800 (PST)
X-Received: by 2002:a25:ad01:: with SMTP id y1mr2522109ybi.696.1640152629236;
Tue, 21 Dec 2021 21:57:09 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 21 Dec 2021 21:57:08 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=98.162.234.209; posting-account=_mt0NQoAAABIfwNsuLpi-_70qS5Wcu3m
NNTP-Posting-Host: 98.162.234.209
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
Subject: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: michaelb...@gmail.com (Michael Ferguson)
Injection-Date: Wed, 22 Dec 2021 05:57:09 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 41
 by: Michael Ferguson - Wed, 22 Dec 2021 05:57 UTC

I just started using the Big_Integer library that is a part of the 202X version of ADA.

It is repeatedly described as an "arbitrary precision library" that has user defined implementation.

I was under the impression that this library would be able to infinitely calculate numbers of any length, but there is clearly a default limit of 300 digits.

Is there any way to get rid of this problem?

Here is some example code:

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Numerics.Big_Numbers.Big_Integers;
use Ada.Numerics.Big_Numbers.Big_Integers;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Test is
package Time_IO is new Fixed_IO(Duration);
start_time, end_time : Ada.Real_Time.Time;
elapsed_seconds : Ada.Real_Time.Time_Span;
solution : Unbounded_String;

rop : Big_Integer;
sum : Big_Integer := 0;

begin
start_time := Ada.Real_Time.Clock;

for i in 1..700 loop
rop := To_Big_Integer(i) ** Natural(i);
sum := sum + rop;
end loop;
solution := To_Unbounded_String(sum'Image);

end_time := Ada.Real_Time.Clock;
elapsed_seconds := end_time - start_time;
Put("Solution: " & solution'Image); New_Line; New_Line;
Put("Program completed in ");
Time_IO.Put(To_Duration(elapsed_seconds), Fore => 0, Aft => 3);
Put(" seconds");
end BigTest;

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<fe7f9aa2-5096-497f-a843-d14ab18a6723n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6402&group=comp.lang.ada#6402

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:7dcd:: with SMTP id c13mr1317551qte.133.1640161526856;
Wed, 22 Dec 2021 00:25:26 -0800 (PST)
X-Received: by 2002:a25:ba05:: with SMTP id t5mr2889509ybg.675.1640161526650;
Wed, 22 Dec 2021 00:25:26 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 22 Dec 2021 00:25:26 -0800 (PST)
In-Reply-To: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.165.155.46; posting-account=Srm5lQoAAAAEMX9rv2ilEKR6FDPapmSq
NNTP-Posting-Host: 93.165.155.46
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fe7f9aa2-5096-497f-a843-d14ab18a6723n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: mark.lor...@gmail.com (Mark Lorenzen)
Injection-Date: Wed, 22 Dec 2021 08:25:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 10
 by: Mark Lorenzen - Wed, 22 Dec 2021 08:25 UTC

On Wednesday, December 22, 2021 at 6:57:10 AM UTC+1, Michael Ferguson wrote:
> I just started using the Big_Integer library that is a part of the 202X version of ADA.
>
> It is repeatedly described as an "arbitrary precision library" that has user defined implementation.
>
> I was under the impression that this library would be able to infinitely calculate numbers of any length, but there is clearly a default limit of 300 digits.
>
How did you determine the limit of 300 digits? I see nothing in your example, that would imply such a limit. Are you sure that you are not reaching a line length limit in Text_IO or maybe a limit in the Image attribute?

Regards,
Mark L

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6403&group=comp.lang.ada#6403

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:915:: with SMTP id v21mr1543881qkv.449.1640171653232;
Wed, 22 Dec 2021 03:14:13 -0800 (PST)
X-Received: by 2002:a25:4156:: with SMTP id o83mr3487063yba.216.1640171653011;
Wed, 22 Dec 2021 03:14:13 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 22 Dec 2021 03:14:12 -0800 (PST)
In-Reply-To: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.100.23; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.100.23
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Wed, 22 Dec 2021 11:14:13 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 6
 by: AdaMagica - Wed, 22 Dec 2021 11:14 UTC

There is a limit
Bignum_Limit : constant := 200;
in System.Generic_Bignums body, function Normalize, lines 1100ff.

I do not see an implementation advice, implementation permission or implementation requirement about such limits in A.5.5, A.5.6.

But there is somewhere in the RM a paragraph stating that implementation may pose limits on certain features. I just cannot find the place in the RM.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<4ac2f7d7-4a93-43a5-929b-cb5289fa53e2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6404&group=comp.lang.ada#6404

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:4495:: with SMTP id x21mr1531804qkp.633.1640172743517;
Wed, 22 Dec 2021 03:32:23 -0800 (PST)
X-Received: by 2002:a25:ba05:: with SMTP id t5mr3742210ybg.675.1640172743339;
Wed, 22 Dec 2021 03:32:23 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 22 Dec 2021 03:32:23 -0800 (PST)
In-Reply-To: <0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.100.23; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.100.23
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com> <0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4ac2f7d7-4a93-43a5-929b-cb5289fa53e2n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Wed, 22 Dec 2021 11:32:23 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 1
 by: AdaMagica - Wed, 22 Dec 2021 11:32 UTC

See RM 1.1.3(2).
I guess this limit is just a transient arbitrary limit until Ada 2022 is standardized.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<c9103e48-64be-4448-a47a-6a666462ab4cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6405&group=comp.lang.ada#6405

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:e0c:: with SMTP id y12mr2439581qkm.109.1640189070179;
Wed, 22 Dec 2021 08:04:30 -0800 (PST)
X-Received: by 2002:a25:7613:: with SMTP id r19mr5216530ybc.498.1640189069892;
Wed, 22 Dec 2021 08:04:29 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 22 Dec 2021 08:04:29 -0800 (PST)
In-Reply-To: <0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.100.23; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.100.23
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com> <0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c9103e48-64be-4448-a47a-6a666462ab4cn@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Wed, 22 Dec 2021 16:04:30 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 1
 by: AdaMagica - Wed, 22 Dec 2021 16:04 UTC

> Bignum_Limit : constant := 200;
RM 2.2(14) limiits the line length and the length of lexical elements to 200.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<spvlm8$qv4$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6406&group=comp.lang.ada#6406

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Lx7EM+81f32E0bqku+QpCA.user.46.165.242.75.POSTED!not-for-mail
From: lagu...@archeia.com (Luke A. Guest)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 17:01:56 +0000
Organization: Aioe.org NNTP Server
Message-ID: <spvlm8$qv4$1@gioia.aioe.org>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="27620"; posting-host="Lx7EM+81f32E0bqku+QpCA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: Luke A. Guest - Wed, 22 Dec 2021 17:01 UTC

On 22/12/2021 05:57, Michael Ferguson wrote:
> I just started using the Big_Integer library that is a part of the 202X version of ADA.
>
> It is repeatedly described as an "arbitrary precision library" that has user defined implementation.
>
> I was under the impression that this library would be able to infinitely calculate numbers of any length, but there is clearly a default limit of 300 digits.

What are you doing that requires that number of digits?

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6407&group=comp.lang.ada#6407

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a0c:8031:: with SMTP id 46mr3345474qva.126.1640194076550;
Wed, 22 Dec 2021 09:27:56 -0800 (PST)
X-Received: by 2002:a25:2d42:: with SMTP id s2mr5541519ybe.646.1640194076263;
Wed, 22 Dec 2021 09:27:56 -0800 (PST)
Path: i2pn2.org!i2pn.org!news.uzoreto.com!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 22 Dec 2021 09:27:56 -0800 (PST)
In-Reply-To: <spvlm8$qv4$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=98.175.171.200; posting-account=_mt0NQoAAABIfwNsuLpi-_70qS5Wcu3m
NNTP-Posting-Host: 98.175.171.200
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com> <spvlm8$qv4$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: michaelb...@gmail.com (Michael Ferguson)
Injection-Date: Wed, 22 Dec 2021 17:27:56 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 19
 by: Michael Ferguson - Wed, 22 Dec 2021 17:27 UTC

On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A. Guest wrote:
> On 22/12/2021 05:57, Michael Ferguson wrote:
> > I just started using the Big_Integer library that is a part of the 202X version of ADA.
> >
> > It is repeatedly described as an "arbitrary precision library" that has user defined implementation.
> >
> > I was under the impression that this library would be able to infinitely calculate numbers of any length, but there is clearly a default limit of 300 digits.
> What are you doing that requires that number of digits?

I am working on ProjectEuler.net problem number 48.

The questions asks you to sum the numbers n^n for (2 <= n <= 1000) and determine what the last ten digits of this number are.

Obviously, this is quite a trivial problem when using any arbitrary precision library.

I had incorrectly determined that 700^700 had 300 digits, in fact 700^700 = 3.7E1991.

However, my code strictly breaks when the loop range is set to 683, which 683^683 = 8.12E1935.

So, that is interesting that the Big_Integer type works numbers of just under 2000 digit length despite Bignum_Limit : constant := 200.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<j2h63aFbvikU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6408&group=comp.lang.ada#6408

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 19:37:45 +0200
Organization: Tidorum Ltd
Lines: 18
Message-ID: <j2h63aFbvikU1@mid.individual.net>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>
<c9103e48-64be-4448-a47a-6a666462ab4cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net tqqaJmMtUY5E09IfNLGXiwdJRTarUg3w7GijgaKGf8B2QzVpO8
Cancel-Lock: sha1:pYc20UZ6CDag1UEBFLZbfeC/btI=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <c9103e48-64be-4448-a47a-6a666462ab4cn@googlegroups.com>
Content-Language: en-US
 by: Niklas Holsti - Wed, 22 Dec 2021 17:37 UTC

On 2021-12-22 18:04, AdaMagica wrote:
>> Bignum_Limit : constant := 200;
> RM 2.2(14) limiits the line length and the length of lexical elements to 200.

To express it more clearly, RM 2.2(14) requires implementations to
support lines and lexical elements of /at least/ 200 characters, but
/allows/ implementations to support longer lines and lexical elements.

I'm not sure if GNAT supports more than 200 characters, though. And of
course an Ada program that uses more than 200 characters may not be
portable to compilers that support only 200.

But I don't see any direct logical connection to the number of digits
that Big_Integers can support. While one cannot write a big-number
literal longer than a line or longer than the maximum length of a
lexical element, that should not directly limit the size of big-number
values in computations.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<87ee64k019.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6409&group=comp.lang.ada#6409

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 17:43:46 +0000
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <87ee64k019.fsf@bsb.me.uk>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="dbe368994a8faf17919528bde6a3c240";
logging-data="26610"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18z86tL3wgdFdm6eJFBPLD7gDPlY1lLIs8="
Cancel-Lock: sha1:ykHHLRwB1AOnjEKAkvrwWbj/H9E=
sha1:cG8qNXR/fF/OveCEecR7a822vd4=
X-BSB-Auth: 1.24c929c914496fb61263.20211222174346GMT.87ee64k019.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 22 Dec 2021 17:43 UTC

Michael Ferguson <michaelblakeferguson@gmail.com> writes:

> On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A. Guest wrote:
>> On 22/12/2021 05:57, Michael Ferguson wrote:
>> > I just started using the Big_Integer library that is a part of the 202X version of ADA.
>> >
>> > It is repeatedly described as an "arbitrary precision library" that has user defined implementation.
>> >
>> > I was under the impression that this library would be able to
>> > infinitely calculate numbers of any length, but there is clearly a
>> > default limit of 300 digits.
>>
>> What are you doing that requires that number of digits?
>
> I am working on ProjectEuler.net problem number 48.
>
> The questions asks you to sum the numbers n^n for (2 <= n <= 1000) and
> determine what the last ten digits of this number are.
>
> Obviously, this is quite a trivial problem when using any arbitrary
> precision library.

Does Ada's Big_Integer type work with modular ranged types?

--
Ben.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<j2h6nrFc4ppU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6410&group=comp.lang.ada#6410

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 19:48:42 +0200
Organization: Tidorum Ltd
Lines: 48
Message-ID: <j2h6nrFc4ppU1@mid.individual.net>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net AmV5n6aUJrBAjEl4CgMKLQzI8b9pnD+F47iZ2Vnc7zrd9Tlxa6
Cancel-Lock: sha1:nsDJbcNcI8l/DXnBJ75UW8duAOo=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
Content-Language: en-US
 by: Niklas Holsti - Wed, 22 Dec 2021 17:48 UTC

On 2021-12-22 19:27, Michael Ferguson wrote:
> On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A. Guest wrote:
>> On 22/12/2021 05:57, Michael Ferguson wrote:
>>> I just started using the Big_Integer library that is a part of the 202X version of ADA.
>>>
>>> It is repeatedly described as an "arbitrary precision library"
>>> that has user defined implementation.

Surely not "user defined"? Possibly "implementation defined".

>>> I was under the impression that this library would be able to
>>> infinitely calculate numbers of any length,

I have the same impression (up to Storage_Error, of course).

>> but there is clearly a default limit of 300 digits.
>> What are you doing that requires that number of digits?
>
> I am working on ProjectEuler.net problem number 48.
>
> The questions asks you to sum the numbers n^n for (2 <= n <= 1000)
> and determine what the last ten digits of this number are.
>
> Obviously, this is quite a trivial problem when using any arbitrary
> precision library.
>
> I had incorrectly determined that 700^700 had 300 digits, in fact
> 700^700 = 3.7E1991.
>
> However, my code strictly breaks when the loop range is set to 683,
> which 683^683 = 8.12E1935.

How does it break? Some exception, or something else?

Mark Lorenzen suggested in an earlier post that the limit might be in
the Big_Integer'Image function. The package
Ada.Numerics.Big_Numbers.Big_Integers has some other output operations
that you could try:

function To_String (Arg : Valid_Big_Integer; ...) return String;

procedure Put_Image (Buffer : ... ; Arg: in Valid_Big_Integer);

Of course those might be internally linked to the 'Image function and
have the same possible limitation.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6411&group=comp.lang.ada#6411

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5a84:: with SMTP id c4mr3015814qtc.565.1640196161902;
Wed, 22 Dec 2021 10:02:41 -0800 (PST)
X-Received: by 2002:a25:c60d:: with SMTP id k13mr5955909ybf.615.1640196161666;
Wed, 22 Dec 2021 10:02:41 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 22 Dec 2021 10:02:41 -0800 (PST)
In-Reply-To: <j2h6nrFc4ppU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=98.175.171.200; posting-account=_mt0NQoAAABIfwNsuLpi-_70qS5Wcu3m
NNTP-Posting-Host: 98.175.171.200
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org> <304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<j2h6nrFc4ppU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: michaelb...@gmail.com (Michael Ferguson)
Injection-Date: Wed, 22 Dec 2021 18:02:41 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 53
 by: Michael Ferguson - Wed, 22 Dec 2021 18:02 UTC

On Wednesday, December 22, 2021 at 11:48:46 AM UTC-6, Niklas Holsti wrote:
> On 2021-12-22 19:27, Michael Ferguson wrote:
> > On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A. Guest wrote:
> >> On 22/12/2021 05:57, Michael Ferguson wrote:
> >>> I just started using the Big_Integer library that is a part of the 202X version of ADA.
> >>>
> >>> It is repeatedly described as an "arbitrary precision library"
> >>> that has user defined implementation.
> Surely not "user defined"? Possibly "implementation defined".
> >>> I was under the impression that this library would be able to
> >>> infinitely calculate numbers of any length,
> I have the same impression (up to Storage_Error, of course).
> >> but there is clearly a default limit of 300 digits.
> >> What are you doing that requires that number of digits?
> >
> > I am working on ProjectEuler.net problem number 48.
> >
> > The questions asks you to sum the numbers n^n for (2 <= n <= 1000)
> > and determine what the last ten digits of this number are.
> >
> > Obviously, this is quite a trivial problem when using any arbitrary
> > precision library.
> >
> > I had incorrectly determined that 700^700 had 300 digits, in fact
> > 700^700 = 3.7E1991.
> >
> > However, my code strictly breaks when the loop range is set to 683,
> > which 683^683 = 8.12E1935.
> How does it break? Some exception, or something else?
>
> Mark Lorenzen suggested in an earlier post that the limit might be in
> the Big_Integer'Image function. The package
> Ada.Numerics.Big_Numbers.Big_Integers has some other output operations
> that you could try:
>
> function To_String (Arg : Valid_Big_Integer; ...) return String;
>
> procedure Put_Image (Buffer : ... ; Arg: in Valid_Big_Integer);
>
> Of course those might be internally linked to the 'Image function and
> have the same possible limitation.

Not 100% sure what modular types are but I did try to do something like the following

subtype VeryBigInteger is Big_Integer range 0 .. 10E10000;

which gave "error: incorrect constraint for this kind of type"

Niklas also gave me an epiphany as the exact error my program gives for the upper limit is

raised STORAGE_ERROR : Ada.Numerics.Big_Numbers.Big_Integers.Bignums.Normalize: big integer limit exceeded

I had thought that since the end of this error said big integer limit exceeded it was a problem with the library, but now I'm starting to think I need to get GNAT to allocated more memory for the program.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<j2hb7eFd05oU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6412&group=comp.lang.ada#6412

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 21:05:18 +0200
Organization: Tidorum Ltd
Lines: 73
Message-ID: <j2hb7eFd05oU1@mid.individual.net>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<j2h6nrFc4ppU1@mid.individual.net>
<41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net ByXtaQdaeHhy8uD1bejhdQDWdggiYfl3UIu/qcjNjBkitx8W25
Cancel-Lock: sha1:iOwWSloawopbdDHvJrXgf2uno4M=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
Content-Language: en-US
 by: Niklas Holsti - Wed, 22 Dec 2021 19:05 UTC

On 2021-12-22 20:02, Michael Ferguson wrote:
> On Wednesday, December 22, 2021 at 11:48:46 AM UTC-6, Niklas Holsti
> wrote:
>> On 2021-12-22 19:27, Michael Ferguson wrote:
>>> On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A.
>>> Guest wrote:
>>>> On 22/12/2021 05:57, Michael Ferguson wrote:
>>>>> I just started using the Big_Integer library that is a part
>>>>> of the 202X version of ADA.
>>>>>

[snip]

> Not 100% sure what modular types are

Types declared with "mod N" instead of "range A .. B", as in:

type Eight_Bits is mod 256;

which declares an unsigned type with a range 0 .. 255 and wrap-around
arithmetic.

Modular types are not connected to Big_Integers, except that the
particular problem you are trying to solve could be computed "mod
10**10" because it asks for only the last 10 digits. However, the
Big_Integers package does not directly support computations "mod"
something (perhaps this should be an extension in a later Ada standard,
because such computations are quite common).

Using "mod 10**10" operations in solving the problem would limit the
number of digits in all intermediate results drastically.

> but I did try to do something like the following
>
> subtype VeryBigInteger is Big_Integer range 0 .. 10E10000;
>
> which gave "error: incorrect constraint for this kind of type"

Indeed, such a range constraint is valid only for (visibly) scalar
types, which Big_Integer is not (it is a private type).

> Niklas also gave me an epiphany as the exact error my program gives
> for the upper limit is
>
> raised STORAGE_ERROR :
> Ada.Numerics.Big_Numbers.Big_Integers.Bignums.Normalize: big integer
> limit exceeded
>
> I had thought that since the end of this error said big integer limit
> exceeded it was a problem with the library, but now I'm starting to
> think I need to get GNAT to allocated more memory for the program.

Perhaps. However, the very specific exception message ("big integer
limit exceeded") suggests that this exception is not a typical
Storage_Error (say, heap or stack exhaustion) but may indeed stem from
exceeding some specific limit in the current Big_Integer implementation
in GNAT.

The size of your problem, with only a few thousand digits, suggests that
heap exhaustion is unlikely to happen. However, if the Big_Integer
computations are internally recursive, and use stack-allocated local
variables, stack overflow could happen, so the first thing to try would
be to increase the stack size. Unfortunately, for the main subprogram
that has to be done with some compiler or linker options which I don't
recall now. (We should really extend pragma Storage_Size to apply also
to the environment task, by specifying it for the main subprogram!)

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<a0730045-de98-462c-a6ab-5b1655852774n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6413&group=comp.lang.ada#6413

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:25ca:: with SMTP id y10mr2994685qko.526.1640201208495;
Wed, 22 Dec 2021 11:26:48 -0800 (PST)
X-Received: by 2002:a05:6902:727:: with SMTP id l7mr6317833ybt.115.1640201208315;
Wed, 22 Dec 2021 11:26:48 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 22 Dec 2021 11:26:48 -0800 (PST)
In-Reply-To: <304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=131.164.234.134; posting-account=Srm5lQoAAAAEMX9rv2ilEKR6FDPapmSq
NNTP-Posting-Host: 131.164.234.134
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org> <304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a0730045-de98-462c-a6ab-5b1655852774n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: mark.lor...@gmail.com (Mark Lorenzen)
Injection-Date: Wed, 22 Dec 2021 19:26:48 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 29
 by: Mark Lorenzen - Wed, 22 Dec 2021 19:26 UTC

On Wednesday, December 22, 2021 at 6:27:57 PM UTC+1, Michael Ferguson wrote:
> On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A. Guest wrote:
> > On 22/12/2021 05:57, Michael Ferguson wrote:
> > > I just started using the Big_Integer library that is a part of the 202X version of ADA.
> > >
> > > It is repeatedly described as an "arbitrary precision library" that has user defined implementation.
> > >
> > > I was under the impression that this library would be able to infinitely calculate numbers of any length, but there is clearly a default limit of 300 digits.
> > What are you doing that requires that number of digits?
> I am working on ProjectEuler.net problem number 48.
>
> The questions asks you to sum the numbers n^n for (2 <= n <= 1000) and determine what the last ten digits of this number are.

Interesting. Assume that the problem is related to the maximum size of lexical elements, can't you then use the "rem" function from Big_Integers to determine the last 10 digits e.g. by something like this Last_10_Digits = My_Very_Large_Number rem To_Big_Integer(1) ** 10?

This should give you a value of type Valid_Big_Integer consisting of up to ten digits that you can obtain the integer representation of.

Regards,
Mark L

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<87ilvgwfdn.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6414&group=comp.lang.ada#6414

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 12:31:32 -0800
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87ilvgwfdn.fsf@nightsong.com>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="dc08b31fa408c994b3052dbcf9f5a79a";
logging-data="6539"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jnYoY9eLrdKHnxSTIW7+O"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:5KETpuF5EJSdqHLSCzkAVCuEyvQ=
sha1:m8CLy0sMtS1DXP10hbIZ+ZECL7Y=
 by: Paul Rubin - Wed, 22 Dec 2021 20:31 UTC

Michael Ferguson <michaelblakeferguson@gmail.com> writes:
> I am working on ProjectEuler.net problem number 48. ...
> Obviously, this is quite a trivial problem when using any arbitrary
> precision library.

The thing about Euler problems is they usually want you to figure out a
clever math trick to get to the solution, rather than using brute
calculation. In the case of this problem, you want to reduce all the
intermediate results mod 1e10 (which fits in an int64 easily, though not
quite in an int32). That gets rid of the need for bignums.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<ly5yrgwf8z.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6415&group=comp.lang.ada#6415

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!8nKyDL3nVTTIdBB8axZhRA.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 20:34:20 +0000
Organization: Aioe.org NNTP Server
Message-ID: <ly5yrgwf8z.fsf@pushface.org>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<0bf093e6-c25b-4541-a5c0-5b840a2e4e06n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="38839"; posting-host="8nKyDL3nVTTIdBB8axZhRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:62RNamBPM9X9iBMn7NzmQ+KYcO0=
 by: Simon Wright - Wed, 22 Dec 2021 20:34 UTC

AdaMagica <christ-usch.grein@t-online.de> writes:

> There is a limit
> Bignum_Limit : constant := 200;
> in System.Generic_Bignums body, function Normalize, lines 1100ff.

This is the maximum length of a Digit_Vector, where

subtype SD is Interfaces.Unsigned_32;
-- Single length digit

type Digit_Vector is array (Length range <>) of SD;
-- Represent digits of a number (most significant digit first)

I think this should give a maximum value of ~10**2000.

I printed out sum'image'length; the last value before the exception was
1937.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<87ee64wf01.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6416&group=comp.lang.ada#6416

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 12:39:42 -0800
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <87ee64wf01.fsf@nightsong.com>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="dc08b31fa408c994b3052dbcf9f5a79a";
logging-data="6539"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KX2LAlrTbeYv6aDWI2x62"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:xDIOyPQ/I6icXhQ8rVJbsnuOkHc=
sha1:3uwkAZ2KU54Dwfvu9gN0AOkoDfU=
 by: Paul Rubin - Wed, 22 Dec 2021 20:39 UTC

Michael Ferguson <michaelblakeferguson@gmail.com> writes:
> However, my code strictly breaks when the loop range is set to 683,
> which 683^683 = 8.12E1935.
>
> So, that is interesting that the Big_Integer type works numbers of
> just under 2000 digit length despite Bignum_Limit : constant := 200.

I wonder if the limit is 6400 bits (200 * 32 bit words) or something
related to that. 2**6400 is roughly 3.9e1926 if my math is right.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<j2hh05Fe364U1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6417&group=comp.lang.ada#6417

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Wed, 22 Dec 2021 22:43:49 +0200
Organization: Tidorum Ltd
Lines: 34
Message-ID: <j2hh05Fe364U1@mid.individual.net>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<a0730045-de98-462c-a6ab-5b1655852774n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net LLSbcYEw3fHXp2xPcdO//wk1rmed7fuvBamKw9gYYYPP9bcukR
Cancel-Lock: sha1:ORfoDALG2Rd7GGWzliNcHXEF72s=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <a0730045-de98-462c-a6ab-5b1655852774n@googlegroups.com>
Content-Language: en-US
 by: Niklas Holsti - Wed, 22 Dec 2021 20:43 UTC

On 2021-12-22 21:26, Mark Lorenzen wrote:
> On Wednesday, December 22, 2021 at 6:27:57 PM UTC+1, Michael Ferguson
> wrote:
>> On Wednesday, December 22, 2021 at 11:02:03 AM UTC-6, Luke A. Guest
>> wrote:
>>> On 22/12/2021 05:57, Michael Ferguson wrote:
>>>> I just started using the Big_Integer library that is a part of
>>>> the 202X version of ADA.
>>>>
>>>> It is repeatedly described as an "arbitrary precision library"
>>>> that has user defined implementation.
>>>>
>>>> I was under the impression that this library would be able to
>>>> infinitely calculate numbers of any length, but there is
>>>> clearly a default limit of 300 digits.
>>> What are you doing that requires that number of digits?
>> I am working on ProjectEuler.net problem number 48.
>>
>> The questions asks you to sum the numbers n^n for (2 <= n <= 1000)
>> and determine what the last ten digits of this number are.
>
> Interesting. Assume that the problem is related to the maximum size
> of lexical elements, can't you then use the "rem" function from
> Big_Integers to determine the last 10 digits e.g. by something like
> this Last_10_Digits = My_Very_Large_Number rem To_Big_Integer(1) **
> 10?

You no doubt meant To_Big_Integer (10), not To_Big_Integer(1).

But it should be possible to write directly "... rem 10_000_000_000",
and even if that constant is too large for the Integer type, because
Big_Integer has the Integer_Literal aspect (assuming GNAT already
implements it).

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<sq1c4k$1geg$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6418&group=comp.lang.ada#6418

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Lx7EM+81f32E0bqku+QpCA.user.46.165.242.75.POSTED!not-for-mail
From: lagu...@archeia.com (Luke A. Guest)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Thu, 23 Dec 2021 08:31:11 +0000
Organization: Aioe.org NNTP Server
Message-ID: <sq1c4k$1geg$1@gioia.aioe.org>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<j2h6nrFc4ppU1@mid.individual.net>
<41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
<j2hb7eFd05oU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="49616"; posting-host="Lx7EM+81f32E0bqku+QpCA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: Luke A. Guest - Thu, 23 Dec 2021 08:31 UTC

On 22/12/2021 19:05, Niklas Holsti wrote:

> Big_Integers package does not directly support computations "mod"
> something (perhaps this should be an extension in a later Ada standard,
> because such computations are quite common).

Is mod overloadable?

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<sq1dg8$3pj$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6419&group=comp.lang.ada#6419

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!6Wzk4cIOQzbtIfSd/aOQqg.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Thu, 23 Dec 2021 09:54:34 +0100
Organization: Aioe.org NNTP Server
Message-ID: <sq1dg8$3pj$1@gioia.aioe.org>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<j2h6nrFc4ppU1@mid.individual.net>
<41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
<j2hb7eFd05oU1@mid.individual.net> <sq1c4k$1geg$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="3891"; posting-host="6Wzk4cIOQzbtIfSd/aOQqg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Thu, 23 Dec 2021 08:54 UTC

On 2021-12-23 09:31, Luke A. Guest wrote:
> On 22/12/2021 19:05, Niklas Holsti wrote:
>
>> Big_Integers package does not directly support computations "mod"
>> something (perhaps this should be an extension in a later Ada
>> standard, because such computations are quite common).
>
> Is mod overloadable?

It is as any operator.

P.S. For large numbers one needs rather full division than separate /,
mod, rem.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<1880ebf1-a27a-4ae1-958b-cfb1e1fe50f2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6420&group=comp.lang.ada#6420

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:1812:: with SMTP id t18mr125563qtc.546.1640259674343;
Thu, 23 Dec 2021 03:41:14 -0800 (PST)
X-Received: by 2002:a25:ed0f:: with SMTP id k15mr2741346ybh.148.1640259674115;
Thu, 23 Dec 2021 03:41:14 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 23 Dec 2021 03:41:13 -0800 (PST)
In-Reply-To: <j2hb7eFd05oU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.100.23; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.100.23
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org> <304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<j2h6nrFc4ppU1@mid.individual.net> <41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
<j2hb7eFd05oU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1880ebf1-a27a-4ae1-958b-cfb1e1fe50f2n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Thu, 23 Dec 2021 11:41:14 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 4
 by: AdaMagica - Thu, 23 Dec 2021 11:41 UTC

Niklas Holsti schrieb am Mittwoch, 22. Dezember 2021 um 20:05:21 UTC+1:
> However, the
> Big_Integers package does not directly support computations "mod"

It does A.5.6(18/5).

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<j2j7osFnt0vU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6422&group=comp.lang.ada#6422

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Thu, 23 Dec 2021 14:18:34 +0200
Organization: Tidorum Ltd
Lines: 19
Message-ID: <j2j7osFnt0vU1@mid.individual.net>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<j2h6nrFc4ppU1@mid.individual.net>
<41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
<j2hb7eFd05oU1@mid.individual.net>
<1880ebf1-a27a-4ae1-958b-cfb1e1fe50f2n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 5O0CP7p+5fMfohUYXt4qhA8Kp7gkvtgQdsbX1LhqlymhCh78XX
Cancel-Lock: sha1:KV5k/hFfqe/KBs8sasoAl4pR3ho=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <1880ebf1-a27a-4ae1-958b-cfb1e1fe50f2n@googlegroups.com>
Content-Language: en-US
 by: Niklas Holsti - Thu, 23 Dec 2021 12:18 UTC

On 2021-12-23 13:41, AdaMagica wrote:
> Niklas Holsti schrieb am Mittwoch, 22. Dezember 2021 um 20:05:21 UTC+1:
>> However, the
>> Big_Integers package does not directly support computations "mod"
>
> It does A.5.6(18/5).

Yes, there is a "mod" operator for Big_Integer. My point was that there
are no Big_Integer operations, such as multiplication, that are
intrinsically modular in the same way as the operations for modular
types are. So the only way to perform a modular multiplication of
Big_Integers is to first multiply the numbers in the usual way,
producing a possibly very large product, and then apply "mod" to reduce
that product.

In my imperfect understanding, intrinsically modular big-number
computations can be much more efficient than such post-computation
applications of "mod", at least if the modulus is not itself a big number.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<87o857ifn8.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6424&group=comp.lang.ada#6424

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Thu, 23 Dec 2021 14:01:47 +0000
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <87o857ifn8.fsf@bsb.me.uk>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
<spvlm8$qv4$1@gioia.aioe.org>
<304dcae2-8b20-43ff-8769-32fa06d4dc10n@googlegroups.com>
<j2h6nrFc4ppU1@mid.individual.net>
<41879a68-95cf-41e7-a582-4358a39f9d47n@googlegroups.com>
<j2hb7eFd05oU1@mid.individual.net>
<1880ebf1-a27a-4ae1-958b-cfb1e1fe50f2n@googlegroups.com>
<j2j7osFnt0vU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="9575ea4c0a77e4149534aaf528f18a76";
logging-data="9317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nzHYEMYakMK3Rg2Fis1/e/BP0JqmOR/4="
Cancel-Lock: sha1:ddZOPeA0MiDA9dfjYYPZSdMv3s0=
sha1:m9T46yehQu/aplmekQGmXswRomk=
X-BSB-Auth: 1.0d21f1495d9682394bf5.20211223140147GMT.87o857ifn8.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 23 Dec 2021 14:01 UTC

Niklas Holsti <niklas.holsti@tidorum.invalid> writes:

> In my imperfect understanding, intrinsically modular big-number
> computations can be much more efficient than such post-computation
> applications of "mod", at least if the modulus is not itself a big
> number.

Yes, there are efficient algorithms for "x * y mod n" so almost all "big
num" libraries provide a function to do it. Ada has the type system for
the mod operation to be explicit in the type.

--
Ben.

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<sq25o3$hg5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6425&group=comp.lang.ada#6425

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
Date: Thu, 23 Dec 2021 16:48:17 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <sq25o3$hg5$1@dont-email.me>
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 23 Dec 2021 15:48:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ad5f227152e353b85606b5fc37fa7aa1";
logging-data="17925"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UTDI/145uD+Qeu6hQ85b8zRR1JZOctMs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Cancel-Lock: sha1:0OtysZVkIht55Rr0vvMHdDAKw0A=
In-Reply-To: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com>
Content-Language: en-US
 by: Jeffrey R.Carter - Thu, 23 Dec 2021 15:48 UTC

On 2021-12-22 06:57, Michael Ferguson wrote:
>
> I was under the impression that this library would be able to infinitely calculate numbers of any length, but there is clearly a default limit of 300 digits.

As it appears from the rest of the discussion that there is a limit in the
implementation of the pkg, you could try using PragmARC.Unbounded_Numbers.Integers

https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-unbounded_numbers-integers.ads

where the implementation restricts a number to Integer'Last "digits" or the
available heap memory, whichever is less.

Note that with recent versions of GNAT for 64-bit processors, the "digits" will
be 64 bits.

--
Jeff Carter
"There's no messiah here. There's a mess all right, but no messiah."
Monty Python's Life of Brian
84

Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?

<96b8f669-57e3-4761-b07b-c189f6513661n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6429&group=comp.lang.ada#6429

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:1721:: with SMTP id az33mr743398qkb.93.1640336993939;
Fri, 24 Dec 2021 01:09:53 -0800 (PST)
X-Received: by 2002:a05:6902:727:: with SMTP id l7mr8033915ybt.115.1640336993738;
Fri, 24 Dec 2021 01:09:53 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 24 Dec 2021 01:09:53 -0800 (PST)
In-Reply-To: <sq25o3$hg5$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.100.23; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.100.23
References: <afc2e263-66d3-4047-aecd-22932484a9a6n@googlegroups.com> <sq25o3$hg5$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <96b8f669-57e3-4761-b07b-c189f6513661n@googlegroups.com>
Subject: Re: Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Fri, 24 Dec 2021 09:09:53 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 10
 by: AdaMagica - Fri, 24 Dec 2021 09:09 UTC

with Ada.Numerics.Big_Numbers.Big_Integers;
use Ada.Numerics.Big_Numbers.Big_Integers;
procedure Ausprobieren is
I: Big_Integer := (1E1000 + 1) / 3;
S: String := I'Image;
begin
Put_Line (S'Last'Image);
Put_Line (I'Image);
end Ausprobieren;

No problem here.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor