Package: Interfaces.Packed_Decimal

Dependencies

with System;

Description

Note that the compiler access the spec of this unit during compilation to obtain the data length that needs allocating, so the correct version of the spec must be available to the compiler, and must correspond to the spec and body made available to the linker, and all units of a given program must be compiled with the same version of the spec and body. This consistency will be enforced automatically using the normal binder consistency checking, since any unit declaring Machine_Radix 10 types or containing operations on such data will implicitly with Packed_Decimal. Format Description

Header

package Interfaces.Packed_Decimal is
 

Constants and Named Numbers

Packed_Size : constant array (1 .. 18) of Byte_Length :=
   (01 => 01,    -- Length in bytes for digits 1
    02 => 02,    -- Length in bytes for digits 2
    03 => 02,    -- Length in bytes for digits 2
    04 => 03,    -- Length in bytes for digits 2
    05 => 03,    -- Length in bytes for digits 2
    06 => 04,    -- Length in bytes for digits 2
    07 => 04,    -- Length in bytes for digits 2
    08 => 05,    -- Length in bytes for digits 2
    09 => 05,    -- Length in bytes for digits 2
    10 => 06,    -- Length in bytes for digits 2
    11 => 06,    -- Length in bytes for digits 2
    12 => 07,    -- Length in bytes for digits 2
    13 => 07,    -- Length in bytes for digits 2
    14 => 08,    -- Length in bytes for digits 2
    15 => 08,    -- Length in bytes for digits 2
    16 => 09,    -- Length in bytes for digits 2
    17 => 09,    -- Length in bytes for digits 2
    18 => 10);
Length in bytes for digits 2

Other Items:

subtype Byte_Length is Positive range 1 .. 10;
The following array must be declared in exactly the form shown, since the compiler accesses the associated tree to determine the size to be allocated to a machine radix 10 type, depending on the number of digits. Range of possible byte lengths

subtype D32 is Positive range 1 .. 9;
Conversion Routines Used to represent number of digits in a packed decimal value that can be represented in a 32-bit binary signed integer form.

subtype D64 is Positive range 10 .. 18;
Used to represent number of digits in a packed decimal value that requires a 64-bit signed binary integer for representing all values.

function Packed_To_Int32 (P : System.Address; D : D32) return Integer_32;
The argument P is the address of a packed decimal value and D is the number of digits (in the range 1 .. 9, as implied by the subtype). The returned result is the corresponding signed binary value. The exception Constraint_Error is raised if the input is invalid.

function Packed_To_Int64 (P : System.Address; D : D64) return Integer_64;
The argument P is the address of a packed decimal value and D is the number of digits (in the range 10 .. 18, as implied by the subtype). The returned result is the corresponding signed binary value. The exception Constraint_Error is raised if the input is invalid.

procedure Int32_To_Packed (V : Integer_32; P : System.Address; D : D32);
The argument V is a signed binary integer, which is converted to packed decimal format and stored using P, the address of a packed decimal item of D digits (D is in the range 1-9). Constraint_Error is raised if V is out of range of this number of digits.

procedure Int64_To_Packed (V : Integer_64; P : System.Address; D : D64);
The argument V is a signed binary integer, which is converted to packed decimal format and stored using P, the address of a packed decimal item of D digits (D is in the range 10-18). Constraint_Error is raised if V is out of range of this number of digits.
end Interfaces.Packed_Decimal;