This package introduces a new type: Mpfloat
, allowing to use mpfr_t
C
objects in Ada code. Mpfloat
is a Limited_Controlled
type, therefore memory
initialization and freeing is automatically handled by Admpfr, thanks to the
Initialize
and Finalize
operations given by the controlled type.
The C developer can consult this document if familiar with the C library.
This section describes how to build Admpfr from the sources. Note that you can
use Alire to get the
Admpfr crate by running alr get admpfr
.
- An Ada 2022 compiler.
- MPFR 4.1.0.
- (Optional) AdaCore's e3-testsuite.
Simply get Alire and run the following commands:
$ cd admpfr
# Export some variable if MPFR is installed in a custom location
$ export LIBRARY_PATH=/usr/local/lib
$ export C_INCLUDE_PATH=/usr/local/include
$ alr build
You can also run the testsuite to ensure everything is properly supported on your system:
$ alr exec -- testsuite/testsuite.py
or just play around with the examples:
$ cd examples
$ alr exec -- gprbuild -Pexamples
$ ./obj/main
1.0000000000000001e-01
The following code:
with Ada.Text_IO; use Ada.Text_IO;
with Admpfr; use Admpfr;
procedure Main is
N : Mpfloat;
begin
N.Set ("0.1");
Put_Line (N'Image);
end Main;
will print:
1.0000000000000001e-01