comp.lang.ada
 help / color / mirror / Atom feed
* Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits?
@ 2021-12-22  5:57 Michael Ferguson
  2021-12-22  8:25 ` Mark Lorenzen
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Michael Ferguson @ 2021-12-22  5:57 UTC (permalink / raw)


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;

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2021-12-24  9:09 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22  5:57 Ada.Numerics.Big_Numbers.Big_Integer has a limit of 300 digits? Michael Ferguson
2021-12-22  8:25 ` Mark Lorenzen
2021-12-22 11:14 ` AdaMagica
2021-12-22 11:32   ` AdaMagica
2021-12-22 16:04   ` AdaMagica
2021-12-22 17:37     ` Niklas Holsti
2021-12-22 20:34   ` Simon Wright
2021-12-22 17:01 ` Luke A. Guest
2021-12-22 17:27   ` Michael Ferguson
2021-12-22 17:43     ` Ben Bacarisse
2021-12-22 17:48     ` Niklas Holsti
2021-12-22 18:02       ` Michael Ferguson
2021-12-22 19:05         ` Niklas Holsti
2021-12-23  8:31           ` Luke A. Guest
2021-12-23  8:54             ` Dmitry A. Kazakov
2021-12-23 11:41           ` AdaMagica
2021-12-23 12:18             ` Niklas Holsti
2021-12-23 14:01               ` Ben Bacarisse
2021-12-22 19:26     ` Mark Lorenzen
2021-12-22 20:43       ` Niklas Holsti
2021-12-22 20:31     ` Paul Rubin
2021-12-22 20:39     ` Paul Rubin
2021-12-23 15:48 ` Jeffrey R.Carter
2021-12-24  9:09   ` AdaMagica

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