DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Ada.Numerics.Big_Numbers.Big_Integers

Mathematical integers, of arbitrary precision in proof and in code.

Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.

Availability and ownership

A proof treats values as mathematical integers, and so does the code: only memory limits a value, and a result memory cannot hold raises Storage_Error. A copy shares its value, which the run time counts and frees with the last holder. Conversion to Integer requires In_Range; division, mod and rem require a nonzero divisor.

A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.

Import and instantiate

with Ada.Numerics.Big_Numbers.Big_Integers;
import Ada.Numerics.Big_Numbers.Big_Integers;

A Vibe module imports this unit's names with from Ada.Numerics.Big_Numbers.Big_Integers import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.

Contract and lifecycle reading

A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.

API 001

Big_Integer (declaration) — Private integer value with mathematical proof semantics and arbitrary precision in code; copies share a counted value (Adjust => Share, Finalize => Release), which needs no action from the user.

Declared interface:

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

API 002

To_Big_Integer (declaration) — Lift Integer into the mathematical/executable big-integer value domain.

API 003

In_Range (declaration) — Test whether a numeric value is between the supplied bounds, inclusive.

API 004

To_Integer (declaration) — Convert a Big_Integer to Integer only after its explicit In_Range precondition.

Before this operation, establish:

In_Range (Arg, To_Big_Integer (Integer'First), To_Big_Integer (Integer'Last))

API 005

To_String (declaration) — Materialize the family's logical text/image as String; consult bounds/content contracts rather than assuming a writable internal view.

API 006

"=" (declaration) — Equality in this declared value/model domain; the family defines whether sequence order, set membership, map pairs or logical text contents are compared.

API 007

"<" (declaration) — Numeric/domain ordering under this declaration; do not substitute it for model subset relations.

API 008

"<=" (declaration) — The declared comparison: ordinary numeric order, sequence prefix, set inclusion or map-pair inclusion according to the parameter types.

API 009

">" (declaration) — Numeric/domain greater-than comparison.

API 010

">=" (declaration) — Numeric/domain greater-or-equal comparison.

API 011

"-" (declaration) — Unary negation, subtraction, time difference or character-set difference according to the profile; their obligations differ.

API 012

"abs" (declaration) — Absolute value in the declared numeric model.

API 013

"+" (declaration) — Addition in the declared numeric/time domain; satisfy overflow/domain conditions of this overload.

API 014

"-" (declaration) — Unary negation, subtraction, time difference or character-set difference according to the profile; their obligations differ.

API 015

"*" (declaration) — Multiplication in numeric domains, or repeated Character construction for Natural*Character.

API 016

"/" (declaration) — Division/quotient in the declared domain; nonzero/finite-domain preconditions must hold, including Big_Integer-to-Big_Real quotient form.

Before this operation, establish:

R /= To_Big_Integer (0)

API 017

"mod" (declaration) — Signed mathematical modulus with the divisor-sign rule; divisor must be nonzero.

Before this operation, establish:

R /= To_Big_Integer (0)

API 018

"rem" (declaration) — Signed remainder with the dividend-sign rule; divisor must be nonzero.

Before this operation, establish:

R /= To_Big_Integer (0)

API 019

""** (declaration) — Exponentiation in the declared model: Natural or explicitly nonnegative Integer exponent, not arbitrary negative powers.

API 020

Share (declaration) — The type's Adjust: a copy holds the value too (the run time counts its holders). Copies call it; a program need not.

API 021

Release (declaration) — The type's Finalize: the object no longer holds its value, which the last holder frees. Finalization calls it; a program need not.