Skip to content

thvnx/admpfr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

main Alire

Ada bindings for MPFR

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.

Build

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.

Prerequisites

Using Alire

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

Example

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