DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Package Ada.Numerics.Big_Numbers.Big_Integers

Ada.Numerics.Big_Numbers.Big_Integers (RM A.5.6). A Big_Integer is an integer of any size: the prover reasons about its values as the mathematical integers, and the code computes them exactly, with as many digits as they need. Only memory limits a value: an operation whose result memory cannot hold raises Storage_Error, as an allocation does. A copy shares its value (which never changes), counted by the run time, and the last holder frees it.

Big_Integer

type Big_Integer is private
  with Finalizable => (Adjust => Share, Finalize => Release, Relaxed_Finalization => True);

To_Big_Integer

function To_Big_Integer (Arg : Integer) return Big_Integer
  with Global => null;

In_Range

function In_Range (Arg, Low, High : Big_Integer) return Boolean
  with Global => null;

To_Integer

function To_Integer (Arg : Big_Integer) return Integer
  with Global => null,
       Pre => In_Range (Arg, To_Big_Integer (Integer'First), To_Big_Integer (Integer'Last));

To_String

function To_String (Arg : Big_Integer) return String
  with Global => null;

the image, as Integer'Image: a space or a minus sign, then the digits

function "=" (L, R : Big_Integer) return Boolean with Global => null;
function "<" (L, R : Big_Integer) return Boolean with Global => null;
function "<=" (L, R : Big_Integer) return Boolean with Global => null;
function ">" (L, R : Big_Integer) return Boolean with Global => null;
function ">=" (L, R : Big_Integer) return Boolean with Global => null;
function "-" (L : Big_Integer) return Big_Integer with Global => null;
function "abs" (L : Big_Integer) return Big_Integer with Global => null;
function "+" (L, R : Big_Integer) return Big_Integer with Global => null;
function "-" (L, R : Big_Integer) return Big_Integer with Global => null;
function "*" (L, R : Big_Integer) return Big_Integer with Global => null;
function "/" (L, R : Big_Integer) return Big_Integer
  with Global => null, Pre => R /= To_Big_Integer (0);
function "mod" (L, R : Big_Integer) return Big_Integer
  with Global => null, Pre => R /= To_Big_Integer (0);
function "rem" (L, R : Big_Integer) return Big_Integer
  with Global => null, Pre => R /= To_Big_Integer (0);
function "**" (L : Big_Integer; R : Natural) return Big_Integer with Global => null;

Share

procedure Share (X : in out Big_Integer)
  with Import, Convention => Ada, External_Name => "verada_rt_big_adjust",
       Global => null, Post => X = X'Old;

a copy holds the value too (the run time counts a value's holders, rt/bignum.c)

Release

procedure Release (X : in out Big_Integer)
  with Import, Convention => Ada, External_Name => "verada_rt_big_finalize",
       Global => null;

X no longer holds its value (the last holder frees it)