From 3427c02d5bd1f74c9e55c8a40af023eac8be4d40 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Wed, 11 Feb 2026 11:38:45 -0300 Subject: [PATCH 1/7] Adding comment about small=delta for decimal fixed-point types --- content/courses/advanced-ada/parts/data_types/numerics.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index 5eb598b78..d0e7e7096 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3113,8 +3113,11 @@ target machine. The *small* must be at least equal to or smaller than the *delta*. In many cases, however, the *small* of a type :ada:`T` is equal to the *delta* of that -type. In addition, note that these values aren't necessarily small numbers -|mdash| in fact, they could be quite large. +type. In addition, for decimal fixed-point types specifically, the *small* is +**always** equal to its *delta*. + +Note that *small* of a type isn't necessarily a small number |mdash| in fact, +it could be quite large. We'll see examples of that later on in this chapter. We can use the :ada:`T'Small` and :ada:`T'Delta` attributes to retrieve the actual values of the *small* and *delta* of a fixed-point type :ada:`T`. (We From e134b1b73eac02c6d95ac68f084c6f8621f47ad1 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Wed, 11 Feb 2026 11:40:07 -0300 Subject: [PATCH 2/7] Editorial change: renaming decimal type Rename `Decimal_6_Digits` => `Decimal_128_Bits` for clarity. --- .../courses/advanced-ada/parts/data_types/numerics.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index d0e7e7096..d9917fc48 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3341,17 +3341,17 @@ Let's see an example using a decimal fixed-point type: procedure Show_Custom_Size_Decimal is - type Decimal_6_Digits is + type Decimal_128_Bits is delta 10.0 ** (-2) digits 6 with Size => 128; begin - Put_Line ("Decimal_6_Digits'Size :" - & Decimal_6_Digits'Size'Image + Put_Line ("Decimal_128_Bits'Size :" + & Decimal_128_Bits'Size'Image & " bits"); end Show_Custom_Size_Decimal; -In this example, we require that :ada:`Decimal_6_Digits` has a size of 128 +In this example, we require that :ada:`Decimal_128_Bits` has a size of 128 bits on the target platform |mdash| instead of the 32 bits that we would typically see for that type on a desktop PC. (As a reminder, this code example won't compile if your target architecture doesn't support 128-bit data types.) From 2ba8f966cc83095c76ef6349e263e8b6c0fc74e7 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Wed, 11 Feb 2026 11:41:38 -0300 Subject: [PATCH 3/7] Editorial change: adding word "type" --- content/courses/advanced-ada/parts/data_types/numerics.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index d9917fc48..891580229 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3490,7 +3490,7 @@ For example, if we multiple the integer representation of the real value by the *delta*, we get the real value: +-------------+-------------------------------+ -| Real value | :ada:`T2_D6` | +| Real value | :ada:`T2_D6` type | | +-------------------------------+ | | Integer representation | | | multiplied by *delta* | From 9b7cd9204119635ed527c4ed5afba86899a2d34f Mon Sep 17 00:00:00 2001 From: gusthoff Date: Wed, 11 Feb 2026 11:43:51 -0300 Subject: [PATCH 4/7] Correction: overlays must refer to objects --- .../courses/advanced-ada/parts/data_types/numerics.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index 891580229..5fffbd64f 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3460,11 +3460,11 @@ machine when assigning values to objects of decimal type. For example: Put_Line ("-----------------------------"); end Show_Machine_Implementation; -In this example, we use the overlays :ada:`Int_T0_D4` and :ada:`Int_T2_D6` to -retrieve the integer representation of the decimal fixed-point types -:ada:`T0_D4` and :ada:`T2_D6`. In the output of this example, we might see the -following integer representation of the real values for the :ada:`T0_D4` and -:ada:`T2_D6` types: +In this example, we use the overlays :ada:`V_Int_T0_D4` and :ada:`V_Int_T2_D6` +to retrieve the integer representation of the decimal variables :ada:`V_T0_D4` +and :ada:`V_T2_D6`. By doing this, we retrieve the machine representation of +the real values for the :ada:`T0_D4` and :ada:`T2_D6` types. The table shows +the values that we get by running the test application: +-------------+-----------------------------+ | Real value | Integer representation | From 978bb920de1baf35867cff1d476fb41a373aaaf6 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Wed, 11 Feb 2026 11:46:55 -0300 Subject: [PATCH 5/7] Correction: scalefactor corresponds to small of the type --- .../advanced-ada/parts/data_types/numerics.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index 5fffbd64f..f6494d861 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3485,15 +3485,20 @@ types on the target machine. The scalefactor is 1 (or 10\ :sup:`0`) for the :ada:`T0_D4` type and 0.01 (or 10\ :sup:`-2`) for the :ada:`T2_D6` type. As you have might have noticed, -this scalefactor corresponds to the *delta* we've used in the type declaration. +this scalefactor is equal to the *delta* we've used in the type declaration. +In actuality, however, the scalefactor is the *small* of the type |mdash| +which, as we've seen before, is equal to the *delta* for decimal fixed-point +types. (Later on, we see that this *detail* makes a difference for ordinary +fixed-point types.) + For example, if we multiple the integer representation of the real value by the -*delta*, we get the real value: +*small*, we get the real value: +-------------+-------------------------------+ | Real value | :ada:`T2_D6` type | | +-------------------------------+ | | Integer representation | -| | multiplied by *delta* | +| | multiplied by the *small* | +=============+===============================+ | 1.00 | = 100 * 0.01 | +-------------+-------------------------------+ From 954d1000421ca5c5b05e8360d539c075cc79a39e Mon Sep 17 00:00:00 2001 From: gusthoff Date: Wed, 11 Feb 2026 11:48:20 -0300 Subject: [PATCH 6/7] Mention small of fixed-point types for machine representation --- .../courses/advanced-ada/parts/data_types/numerics.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index f6494d861..5b269996c 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3362,10 +3362,11 @@ won't compile if your target architecture doesn't support 128-bit data types.) Machine representation of fixed-point types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In this section, we discuss how fixed-point types are typically -represented in actual hardware. For that, we can use -:ref:`overlays ` to retrieve the actual integer -representation on the machine of objects of the fixed-point type. +In this section, we discuss how fixed-point types are represented in actual +hardware. Typically, the machine representation of objects of fixed-point type +consists of integer values scaled by the *small* of the type. To retrieve +the actual integer representation, we can use +:ref:`overlays `. .. _Adv_Ada_Decimal_Fixed_Point_Machine_Representation: From b89d2ae988a4a35a23156edcbb0521b62d29c243 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Wed, 11 Feb 2026 17:55:29 -0300 Subject: [PATCH 7/7] Minor change: adding word: "implicitly" --- content/courses/advanced-ada/parts/data_types/numerics.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index 5b269996c..c7cbd2b24 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3364,8 +3364,8 @@ Machine representation of fixed-point types In this section, we discuss how fixed-point types are represented in actual hardware. Typically, the machine representation of objects of fixed-point type -consists of integer values scaled by the *small* of the type. To retrieve -the actual integer representation, we can use +consists of integer values implicitly scaled by the *small* of the type. To +retrieve the actual integer representation, we can use :ref:`overlays `.