@@ -4006,11 +4006,11 @@ precision.
40064006In the example below, we declare two data types: :ada: `T3_D3 ` and :ada: `T6_D3 `.
40074007For both types, the *delta * is the same: 0.001.
40084008
4009- .. code :: ada run_button project=Courses.Advanced_Ada.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Types
4009+ .. code :: ada run_button project=Courses.Advanced_Ada.Decimal_Fixed_Point_Types.Decimal_Precision
40104010
40114011 with Ada.Text_IO; use Ada.Text_IO;
40124012
4013- procedure Decimal_Fixed_Point_Types is
4013+ procedure Show_Decimal_Precision is
40144014 type T3_D3 is delta 10.0 ** (-3) digits 3;
40154015 type T6_D3 is delta 10.0 ** (-3) digits 6;
40164016 begin
@@ -4028,7 +4028,7 @@ For both types, the *delta* is the same: 0.001.
40284028 & T6_D3'Image (T6_D3'First));
40294029 Put_Line ("The maximum value of T6_D3 is "
40304030 & T6_D3'Image (T6_D3'Last));
4031- end Decimal_Fixed_Point_Types ;
4031+ end Show_Decimal_Precision ;
40324032
40334033When running the application, we confirm that the delta value of both
40344034types is indeed the same: 0.001. However, because :ada: `T3_D3 ` is restricted
@@ -4277,7 +4277,7 @@ contrast, for decimal fixed-point types, each digit increases the type's size.
42774277Note, however, that the *delta * of the decimal type doesn't have an influence
42784278on the type's size. For example:
42794279
4280- .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Decimal_Precision
4280+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Size
42814281
42824282 package Decimal_Types is
42834283
@@ -4364,7 +4364,7 @@ on the type's size. For example:
43644364
43654365 with Decimal_Types; use Decimal_Types;
43664366
4367- procedure Show_Decimal_Digits is
4367+ procedure Show_Decimal_Digits_Size is
43684368 begin
43694369 Put_Line ("Decimal_1_Digits'Size :"
43704370 & Decimal_1_Digits'Size'Image
@@ -4480,7 +4480,7 @@ on the type's size. For example:
44804480 Put_Line ("Decimal_38_Digits'Size :"
44814481 & Decimal_38_Digits'Size'Image
44824482 & " bits");
4483- end Show_Decimal_Digits ;
4483+ end Show_Decimal_Digits_Size ;
44844484
44854485When running the application above, we see that the number of bits increases
44864486for each digit that we *add * to our decimal type declaration. On a typical
@@ -4517,13 +4517,13 @@ desktop PC, we may see the following results:
45174517When we look at the base type of these decimal fixed-point types, we see that
45184518the actual size on hardware is usually bigger. For example:
45194519
4520- .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Decimal_Precision
4520+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Size
45214521
45224522 with Ada.Text_IO; use Ada.Text_IO;
45234523
45244524 with Decimal_Types; use Decimal_Types;
45254525
4526- procedure Show_Decimal_Digits is
4526+ procedure Show_Decimal_Digits_Size is
45274527 begin
45284528 Put_Line ("Decimal_1_Digits'Base'Size :"
45294529 & Decimal_1_Digits'Base'Size'Image
@@ -4639,7 +4639,7 @@ the actual size on hardware is usually bigger. For example:
46394639 Put_Line ("Decimal_38_Digits'Base'Size :"
46404640 & Decimal_38_Digits'Base'Size'Image
46414641 & " bits");
4642- end Show_Decimal_Digits ;
4642+ end Show_Decimal_Digits_Size ;
46434643
46444644On a typical desktop PC, we may see the following results:
46454645
@@ -4696,11 +4696,11 @@ that the decimal fixed-point type is able to represent. For example, by writing
46964696represent values with three digits ranging from -999 to 999 |mdash | this
46974697corresponds to a range from -10\ :sup: `3` + 1 to 10\ :sup: `3` - 1. For example:
46984698
4699- .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Decimal_Precision
4699+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Range
47004700
47014701 with Ada.Text_IO; use Ada.Text_IO;
47024702
4703- procedure Show_Decimal_Digits is
4703+ procedure Show_Decimal_Range is
47044704
47054705 type D1 is
47064706 delta 1.0 digits 1;
@@ -4734,7 +4734,7 @@ corresponds to a range from -10\ :sup:`3` + 1 to 10\ :sup:`3` - 1. For example:
47344734 & D38'First'Image
47354735 & " .. "
47364736 & D38'Last'Image);
4737- end Show_Decimal_Digits ;
4737+ end Show_Decimal_Range ;
47384738
47394739In this example, we declare multiple decimal types. This is the range of each
47404740one of them:
@@ -4776,11 +4776,11 @@ Custom range of decimal fixed-point types
47764776Similar to floating-point types, we can define custom ranges for decimal
47774777fixed-point types by using the :ada: `range ` keyword. For example:
47784778
4779- .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Decimal_Precision
4779+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Custom_Range
47804780
47814781 with Ada.Text_IO; use Ada.Text_IO;
47824782
4783- procedure Show_Decimal_Digits is
4783+ procedure Show_Decimal_Custom_Range is
47844784
47854785 type D6 is
47864786 delta 1.0 digits 6;
@@ -4797,7 +4797,7 @@ fixed-point types by using the :ada:`range` keyword. For example:
47974797 & D6_R100'First'Image
47984798 & " .. "
47994799 & D6_R100'Last'Image);
4800- end Show_Decimal_Digits ;
4800+ end Show_Decimal_Custom_Range ;
48014801
48024802In this example, we declare the :ada: `D6 ` type with :ada: `digits 6 `, which
48034803has a range between -999,999.0 and 999,999.0. In addition, we declare the
@@ -4811,16 +4811,18 @@ Range of derived decimal fixed-point types
48114811We can also derive from decimal fixed-point types and limit the range at the
48124812same time |mdash | as we can do with floating-point types. For example:
48134813
4814- .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Decimal_Precision
4814+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Derived_Decimal_Fixed_Point_Range
48154815
48164816 with Ada.Text_IO; use Ada.Text_IO;
48174817
4818- procedure Show_Decimal_Digits is
4818+ procedure Show_Derived_Decimal_Range is
48194819
48204820 type D6 is
48214821 delta 1.0 digits 6;
4822+
48224823 type D6_RD3 is new D6
48234824 range -999.0 .. 999.0;
4825+
48244826 type D6_R5 is new D6
48254827 range -5.0 .. 5.0;
48264828
@@ -4837,7 +4839,7 @@ same time |mdash| as we can do with floating-point types. For example:
48374839 & D6_R5'First'Image
48384840 & " .. "
48394841 & D6_R5'Last'Image);
4840- end Show_Decimal_Digits ;
4842+ end Show_Derived_Decimal_Range ;
48414843
48424844Here, :ada: `D6_RD3 ` and :ada: `D6_R5 ` types are both derived from the :ada: `D6 `
48434845type, which ranges from -999,999.0 to 999,999.0. For the derived type
@@ -4852,18 +4854,21 @@ Range of decimal fixed-point subtypes
48524854Similarly, we can declare subtypes of decimal fixed-point types and limit the
48534855range at the same time. For example:
48544856
4855- .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Decimal_Precision
4857+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Subtype_Range
48564858
48574859 with Ada.Text_IO; use Ada.Text_IO;
48584860
4859- procedure Show_Decimal_Digits is
4861+ procedure Show_Decimal_Subtype_Range is
48604862
48614863 type D6 is
48624864 delta 1.0 digits 6;
4865+
48634866 subtype D6_RD3 is D6
48644867 range -999.0 .. 999.0;
4868+
48654869 subtype D6_R5 is D6
48664870 range -5.0 .. 5.0;
4871+
48674872 begin
48684873 Put_Line ("D6'Range : "
48694874 & D6'First'Image
@@ -4877,7 +4882,7 @@ range at the same time. For example:
48774882 & D6_R5'First'Image
48784883 & " .. "
48794884 & D6_R5'Last'Image);
4880- end Show_Decimal_Digits ;
4885+ end Show_Decimal_Subtype_Range ;
48814886
48824887Now, :ada: `D6_RD3 ` and :ada: `D6_R5 ` are subtypes of the :ada: `D6 ` type, which
48834888has a range between -999,999.0 to 999,999.0. For these subtypes, we use the
@@ -4892,11 +4897,11 @@ Range of the base type
48924897Note that the range of a decimal fixed-point type might be smaller than the
48934898range of its :ref: `base type <Adv_Ada_Base_Types >`. For example:
48944899
4895- .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Decimal_Precision
4900+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Decimal_Fixed_Point_Types.Decimal_Fixed_Point_Base_Range
48964901
48974902 with Ada.Text_IO; use Ada.Text_IO;
48984903
4899- procedure Show_Decimal_Digits is
4904+ procedure Show_Decimal_Fixed_Point_Base_Range is
49004905
49014906 type D6 is
49024907 delta 1.0 digits 6;
@@ -4910,7 +4915,7 @@ range of its :ref:`base type <Adv_Ada_Base_Types>`. For example:
49104915 & D6'Base'First'Image
49114916 & " .. "
49124917 & D6'Base'Last'Image);
4913- end Show_Decimal_Digits ;
4918+ end Show_Decimal_Fixed_Point_Base_Range ;
49144919
49154920In this example, we see that the range of the :ada: `D6 ` goes from -999,999 to
49164921999,999. The range of the base type, however, can be wider. On a desktop PC, it
0 commit comments