ADA - Ada.Numerics.Big_Numbers.Big_Integer has upper limit?

  • Thread starter Thread starter MFerguson
  • Start date Start date
  • Tags Tags
    Limit
Click For Summary

Discussion Overview

The discussion revolves around the limitations of the Big_Integer library in the 202X version of ADA, particularly concerning its capacity for arbitrary precision calculations. Participants explore the implications of a default limit of 300 digits and seek solutions or clarifications regarding this limitation.

Discussion Character

  • Debate/contested
  • Technical explanation

Main Points Raised

  • One participant expresses confusion about the Big_Integer library's claim of being an "arbitrary precision library," noting a default limit of 300 digits and asking if this limit can be removed.
  • Another participant questions whether the focus should be on Big Integers or arbitrary precision reals, suggesting that a limit is necessary for certain calculations to terminate.
  • A separate post clarifies the distinction between ADA as an acronym and Ada as the programming language, providing historical context about Ada Lovelace and her contributions.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the nature of the limitations of the Big_Integer library, with differing views on whether the limit is a necessary feature or a drawback. The discussion remains unresolved regarding potential solutions to the stated limit.

Contextual Notes

There is uncertainty regarding the definitions and implications of "arbitrary precision" in the context of the library, as well as the specific nature of the limit imposed on digit length. The conversation does not clarify whether the limit can be modified or removed.

MFerguson
Messages
1
Reaction score
0
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;
 
Technology news on Phys.org
Do you want Big Integers or arbitrary precision reals? If the latter then there must be a (modifiable) limit otherwise the calculation of e.g. 1/10 would not terminate.
 
Last edited:
  • Like
Likes   Reactions: sysprog
MFerguson said:
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:
 
ADA is not the Ada programming language. The former is an acronym, a three letter one at that. The latter, Ada, is the name of the programming language, named after Ada Lovelace, credited by many as being one of, or the first programmer. She worked with Charles Babbage in the mid Nineteenth Century in designing an analytic machine, later evolved into modern digital computers.
 

Similar threads

  • · Replies 49 ·
2
Replies
49
Views
12K