Very simple queston here. I just need a quick hint.
I have a very simple program that uses the GNAT Big_Integer library. I want to use the libgmp Ada library in conjunction with the GNAT Big_Integer library. I know how to do the with (and use) bit, but I’m sure that there is something else that I need to do as well but I’m just not seeing what it is; I’m sure it is very obvious and simple.
Here is my simple program that uses GNAT Big_Integer:
‘’'ada
pragma Ada_2022;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers;
procedure test_without_libgmp is
Biggest_Integer : Positive := Positive’Last;
Test_Very_Big_Int : Big_Integer := To_Big_Integer (Biggest_Integer) ** 5;
begin
Put_Line (To_String (Test_Very_Big_Int));
end test_without_libgmp;
‘’’
(formatting: you need to surround code blocks like this with three backticks, not plain apostrophes)
The package is GNATCOLL.GMP.Integers. It exports a type also named Big_Integer, so if you want to use both packages in the same unit you’ll have to use some package renamings, and be very careful with use.
What sparked (pun not intended) my question was this:
Could you clarify how this is distinct from the GNATCOLL.GMP.Integers package? (or not?) This package claims to speed up the GNAT Big_Integers by putting GMP underneath it (?)
Ada.Numerics.Big_Numbers.Big_Integers is implemented (in GCC 14) over System.Generic_Bignums, without any trace of GMP.
For me, this bears some similarity to the case of Annex G. To start with, AdaCore implemented this over BLAS and LAPACK. Because some of AdaCore’s customers couldn’t use those packages, the Annex G code was reimplemented using native Ada; portability increased, speed decreased (quite a lot, last time I measured).