TABLE OF CONTENTS
- 1. Cashe/Cashe
- 1.1. Cashe/Currency_Handling
- 1.1.1. Currency_Handling/Currency_Handling.Currency_Type
- 1.1.2. Currency_Handling/Currency_Handling.Custom_Currency
- 1.1.2.1. Currency_Handling.Custom_Currency/Code
- 1.1.2.2. Currency_Handling.Custom_Currency/Name
- 1.1.2.3. Currency_Handling.Custom_Currency/Set_Code
- 1.1.2.4. Currency_Handling.Custom_Currency/Set_Name
- 1.1.2.5. Currency_Handling.Custom_Currency/Set_Symbol
- 1.1.2.6. Currency_Handling.Custom_Currency/Set_Unit
- 1.1.2.7. Currency_Handling.Custom_Currency/Symbol
- 1.1.2.8. Currency_Handling.Custom_Currency/Unit
- 1.1.3. Currency_Handling/Currency_Handling.Currency_Data
- 1.1.4. Currency_Handling/Currency_Handling.Create
- 1.2. Cashe/Exchange
- 1.2.1. Exchange/Exchange.Currency_Exchange
- 1.2.1.1. Exchange.Currency_Exchange/Base_Is_Set
- 1.2.1.2. Exchange.Currency_Exchange/Contains
- 1.2.1.3. Exchange.Currency_Exchange/Convert
- 1.2.1.4. Exchange.Currency_Exchange/Rate
- 1.2.1.5. Exchange.Currency_Exchange/Set_Base
- 1.2.1.6. Exchange.Currency_Exchange/Set_Rate
- 1.3. Cashe/Money_Handling
- 1.3.1. Money_Handling/Money_Handling.Money
- 1.3.1.1. Money_Handling.Money/As_Major
- 1.3.1.2. Money_Handling.Money/As_Minor
- 1.3.1.3. Money_Handling.Money/Currency_Code
- 1.3.1.4. Money_Handling.Money/Currency_Name
- 1.3.1.5. Money_Handling.Money/Currency_Symbol
- 1.3.1.6. Money_Handling.Money/Currency_Unit
- 1.3.1.7. Money_Handling.Money/Full_Precision
- 1.3.1.8. Money_Handling.Money/Get_Currency
- 1.3.1.9. Money_Handling.Money/Is_Custom_Currency
- 1.3.1.10. Money_Handling.Money/Is_Negative
- 1.3.1.11. Money_Handling.Money/Is_Positive
- 1.3.1.12. Money_Handling.Money/Is_Zero
- 1.3.1.13. Money_Handling.Money/Round
- 1.3.1.14. Money_Handling.Money/Same_Currency
- 1.3.2. Money_Handling/Money_Handling.Currency_Mismatch
- 1.3.3. Money_Handling/Money_Handling.Division_By_Zero
- 1.3.4. Money_Handling/Money_Handling.abs
- 1.3.5. Money_Handling/Money_Handling.Addition
- 1.3.6. Money_Handling/Money_Handling.Division
- 1.3.7. Money_Handling/Money_Handling.Equal_To
- 1.3.8. Money_Handling/Money_Handling.From_Major
- 1.3.9. Money_Handling/Money_Handling.From_Minor
- 1.3.10. Money_Handling/Money_Handling.Greater_Than
- 1.3.11. Money_Handling/Money_Handling.Greater_Than_Equal_To
- 1.3.12. Money_Handling/Money_Handling.Less_Than
- 1.3.13. Money_Handling/Money_Handling.Less_Than_Equal_To
- 1.3.14. Money_Handling/Money_Handling.Multiplication
- 1.3.15. Money_Handling/Money_Handling.Print_Money
- 1.3.16. Money_Handling/Money_Handling.Subtraction
- 1.4. Cashe/Cashe.Decimal
- 1.5. Cashe/Cashe.Decimal_Major
- 1.6. Cashe/Cashe.Decimal_Minor
- 1.7. Cashe/Cashe.Round_Method
- 1.8. Cashe/Cashe.Max_Integer_Len
- 1.9. Cashe/Cashe.Max_Precision
- 1.10. Cashe/Cashe.Minor_Unit_Too_Large
- 1.11. Cashe/Cashe.Round
- 1.12. Cashe/Cashe.To_Decimal
Cashe/Cashe [ Packages ]
DESCRIPTION
This package provides datatypes and functions utilized by other packages.
SOURCE
package Cashe is
Cashe/Cashe.Decimal [ Types ]
DESCRIPTION
128-bit decimal number, ranging from: -999_999_999_999_999_999.99999999999999999999 to 999_999_999_999_999_999.99999999999999999999 Used for storing the currency.
SOURCE
type Decimal is delta 1.0E-20 digits 38;
EXAMPLE
-- My_Dec : Decimal := 1.12345678909876543210;
Cashe/Cashe.Decimal_Major [ Types ]
DESCRIPTION
Integer number, ranging from: -999_999_999_999_999_999 to 999_999_999_999_999_999 Used for setting major units without precision.
SOURCE
subtype Decimal_Major is Long_Long_Integer range -(1E+18 - 1) .. +(1E+18 - 1);
DERIVED FROM
Long_Long_Integer
Cashe/Cashe.Decimal_Minor [ Types ]
DESCRIPTION
128-bit integer number, ranging from: -99_999_999_999_999_999_999_999_999_999_999_999_999 to 99_999_999_999_999_999_999_999_999_999_999_999_999 Used for setting / accessing minor units
SOURCE
subtype Decimal_Minor is Long_Long_Long_Integer range -(1E+38 - 1) .. +(1E+38 - 1);
DERIVED FROM
Long_Long_Long_Integer
Cashe/Cashe.Round_Method [ Types ]
DESCRIPTION
Rounding methods.
SOURCE
type Round_Method is ( Half_Even, -- Default rounding method, also known as "Banker's Rounding" Half_Up -- Standard-behavior rounding, the kind taught in highschool. );
Cashe/Cashe.Max_Integer_Len [ Constants ]
[ Top ] [ Cashe ] [ Constants ]
DESCRIPTION
The maximum number of decimal numbers that a major unit can be.
SOURCE
Max_Integer_Len : constant := 18;
Cashe/Cashe.Max_Precision [ Constants ]
[ Top ] [ Cashe ] [ Constants ]
DESCRIPTION
The maximum precision that this decimal type has.
SOURCE
Max_Precision : constant := 20;
Cashe/Cashe.Minor_Unit_Too_Large [ Exceptions ]
[ Top ] [ Cashe ] [ Exceptions ]
DESCRIPTION
Raised if the minor unit will not "fit" into the major unit.
SOURCE
Minor_Unit_Too_Large : exception;
Cashe/Cashe.Round [ Subprograms ]
[ Top ] [ Cashe ] [ Subprograms ]
SOURCE
function Round (Item : Decimal; -- The decimal to round By : Natural; -- The precision which to round to. Method : Round_Method := Half_Even -- The method of rounding. Default is Half_Even aka Banker's Rounding. ) return Decimal with pre => By <= Max_Precision;
PARAMETERS
Item - Decimal to be rounded By - Precision to round to.
EXAMPLE
-- T : Decimal := -2000.005; -- A : Decimal := Round (T, 2); -- -2000.00 -- B : Decimal := Round (T, 2, Half_Up); -- -2000.01
FUNCTION
Round the value of a money object to a given precision
RETURN VALUE
Cashe.Decimal - Decimal value rounded to Precision.
Cashe/Cashe.To_Decimal [ Subprograms ]
[ Top ] [ Cashe ] [ Subprograms ]
ERRORS
* Cashe/Cashe.Minor_Unit_Too_Large in case of converting Minor Unit
SOURCE
function To_Decimal (Item : Float; -- Floating point to be converted to a decimal. Precision : Natural := 20 -- Precision to round to. Default is 20. ) return Decimal; function To_Decimal (Item : Long_Float; -- Floating point to be converted to a decimal. Precision : Natural := 20 -- Precision to round to. Default is 20. ) return Decimal; function To_Decimal (Item : Long_Long_Float; -- Floating point to be converted to a decimal. Precision : Natural := 20 -- Precision to round to. Default is 20. ) return Decimal; function To_Decimal (Value : Decimal_Minor; -- The whole number which to convert into a decimal Precision : Natural := 20 -- The maount of decimal places out ) return Decimal with pre => Precision <= Max_Precision;
PARAMETERS
Item - Floating point to be converted. Precision - Precision to round to. Default is 20.
EXAMPLE
-- with Cashe; use Cashe; -- D : Decimal_Minor := 1411900 -- F : Long_Long_Float := 14.1190004014938372284932918; -- A : Decimal := To_Decimal (F); -- 14.11900040149383722880 -- B : Decimal := To_Decimal (F, 3); -- 14.11900000000000000000 -- C : Decimal := To_Decimal (F, 2); -- 14.12000000000000000000 -- E : Decimal := To_Decimal (D, 5); -- 14.11900
FUNCTION
Convert a floating point number or minor unit to a Decimal based on precision. Highly recommended to use this function with Long_Long_Float for highest precision.
RETURN VALUE
Cashe.Decimal - Decimal value of float to Precision.