6.7. Numeric Types - JulTob/Ada GitHub Wiki
👩🏻🏫 The other fundamental types are the numeric types. One way or another, all other data types are built out of enumeration types and numeric types.
👩🏻🔬 The two major classes of numeric types are the integer types and floating point types.
👮🏻♀️ The integer types are further subdivided into signed integer types (such as Integer) and unsigned or modular types.
💂🏻♀️All implementations have the types following types:
-- Mains
Integer -- From -2147483648 to 2147483647
Float -- From -3.40282E+38 to 3.40282E+38
-- Integers
Natural -- From 0 to 2147483647
Positive -- From 1 to 2147483647
-- subtype Positive is integer 1..Integer'Last;
Long_Integer -- From -9223372036854775808 to 9223372036854775807
Long_Long_Integer -- From -9223372036854775808 to 9223372036854775807
Short_Integer -- From -32768 to 32767
Short_Short_Integer -- From -128 to 127
-- Floats
Long_Float -- From -1.79769313486232E+308 to 1.79769313486232E+308
Long_Long_Float -- From -1.18973149535723177E+4932 to 1.18973149535723177E+4932
Short_Float -- From -3.40282E+38 to 3.40282E+38
🕵🏻♀️ There will also be specific integer types for an implementation depending upon the supported word lengths such as Integer_16
and unsigned types such as Unsigned_16
.
Count : Integer;
X, Y, Z : Integer;
Amount : Integer := 0;
Put_Line("The min range of an integer [" &
Integer'Image(Integer'First) & "] and the max range of an integer [" &
Integer'Image(Integer'Last) & "].");
n : Natural := 0; -- Subset of Integer {0..Max}
pos : Positive := 1; -- Subset of Integer {1..Max}
Put_Line("The min range of a positive ["
& Positive'Image(Positive'First)
& "] and the max range of a positive ["
& Positive'Image(Positive'Last)
& "].");
Put_Line("The min range of a natural [" &
Natural'Image(Natural'First) & "] and the max range of a natural [" &
Natural'Image(Natural'Last) & "].");
Speed_Of_Light : constant := 300_000;
-- Type, universal_integer
A_Month : Integer range 1..12;
var : float;
a, b, c : float := 0.0;
pi : constant float := 3.14_15_92;
Avogadro : constant := 6.027E23
-- Type, universal_float
-- in begin body:
X := 10_000;
Y := 10e4
Z := 10E4 --Same values
A := 12.10; -- is the variable float declared "a"
B := 1.0E-12; -- is the variable float declared "b"
Byte := 2#1000_0100_0010_0001#
Mask := 16#FFF0#
All bases 2..8 are allowed
Type Distance is digits 10;
Type temperature is digits 5 range -273.15 .. 1_000_000.0;