From 2dedef757830db9894813a4b9ad195b7702f0af7 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 22:58:15 +0100 Subject: [PATCH 01/10] Editorial change: correcting project name in code examples --- .../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 33a89f788..d80c58a4f 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -3363,7 +3363,7 @@ it's always equal to the *delta*. For example, we may define a normalized range between -1.0 and 1.0 as following: - .. code:: ada run_button project=Courses.Intro_To_Ada.Fixed_Point_Types.Normalized_Fixed_Point_Type + .. code:: ada run_button project=Courses.Advanced_Ada.Fixed_Point_Types.Normalized_Fixed_Point_Type with Ada.Text_IO; use Ada.Text_IO; @@ -3390,7 +3390,7 @@ it's always equal to the *delta*. We may also rewrite this code with an exact type definition: - .. code:: ada compile_button project=Courses.Intro_To_Ada.Fixed_Point_Types.Normalized_Adapted_Fixed_Point_Type + .. code:: ada compile_button project=Courses.Advanced_Ada.Fixed_Point_Types.Normalized_Adapted_Fixed_Point_Type procedure Normalized_Adapted_Fixed_Point_Type is type TQ31 is @@ -3402,7 +3402,7 @@ it's always equal to the *delta*. We may also use any other range. For example: - .. code:: ada run_button project=Courses.Intro_To_Ada.Fixed_Point_Types.Custom_Fixed_Point_Range + .. code:: ada run_button project=Courses.Advanced_Ada.Fixed_Point_Types.Custom_Fixed_Point_Range with Ada.Text_IO; use Ada.Text_IO; with Ada.Numerics; use Ada.Numerics; @@ -3431,7 +3431,7 @@ it's always equal to the *delta*. All standard operations are available for fixed-point types. For example: - .. code:: ada run_button project=Courses.Intro_To_Ada.Fixed_Point_Types.Fixed_Point_Op + .. code:: ada run_button project=Courses.Advanced_Ada.Fixed_Point_Types.Fixed_Point_Op with Ada.Text_IO; use Ada.Text_IO; From 6d11cb07a78ec69cda6c3f4a082d4e03d2ce7a2d Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 22:59:19 +0100 Subject: [PATCH 02/10] Editorial change: correcting project name in code examples --- .../parts/data_types/numeric_attributes.rst | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst b/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst index 6638b00a6..f0a47d57f 100644 --- a/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst +++ b/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst @@ -24,7 +24,7 @@ universal integer value. Let's get the modulus of the 32-bit :ada:`Modular` type that we've declared in the :ada:`Num_Types` package of the previous chapter: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1 +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Modular_Types.Modular_1 package Num_Types is @@ -69,7 +69,7 @@ be something like :ada:`-2**31 .. 2**31 - 1`. (Note: we discussed the Operations on modular integers use modular (wraparound) arithmetic. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1 +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Modular_Types.Modular_1 with Ada.Text_IO; use Ada.Text_IO; @@ -94,7 +94,7 @@ wrap around)? The answer in Ada is the former |mdash| that is, if you try to convert, say, :ada:`Integer'(-1)` to :ada:`Modular`, you will get :ada:`Constraint_Error`: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1 +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Modular_Types.Modular_1 :class: ada-run-expect-failure with Ada.Text_IO; use Ada.Text_IO; @@ -111,7 +111,7 @@ convert, say, :ada:`Integer'(-1)` to :ada:`Modular`, you will get To solve this problem, we can use the :ada:`Mod` attribute: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Modular_1 +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Modular_Types.Modular_1 with Ada.Text_IO; use Ada.Text_IO; @@ -140,7 +140,7 @@ given modular type, using wraparound semantics. The :ada:`Mod` attribute was added to Ada 2005 to solve this problem. Also, we can now safely use this attribute in generics. For example: - .. code:: ada compile_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Mod_Attribute + .. code:: ada compile_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Modular_Types.Mod_Attribute generic type Formal_Modular is mod <>; @@ -180,7 +180,7 @@ performed. Let's see a simple implementation of the CRC-CCITT (0x1D0F) algorithm: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Modular_Types.Mod_Crc_CCITT_Ada +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Modular_Types.Mod_Crc_CCITT_Ada package Crc_Defs is @@ -298,7 +298,7 @@ Attribute: :ada:`Machine_Radix` :ada:`Machine_Radix` is an attribute that returns the radix of the hardware representation of a type. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Machine_Radix +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Machine_Radix with Ada.Text_IO; use Ada.Text_IO; @@ -324,7 +324,7 @@ Attributes: :ada:`Machine_Mantissa` :ada:`Machine_Mantissa` is an attribute that returns the number of bits reserved for the mantissa of the floating-point type. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Machine_Mantissa +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Machine_Mantissa with Ada.Text_IO; use Ada.Text_IO; @@ -352,7 +352,7 @@ and maximum value, respectively, of the machine exponent the floating-point type. Note that, in all cases, the returned value is a universal integer. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Machine_Emin_Emax +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Machine_Emin_Emax with Ada.Text_IO; use Ada.Text_IO; @@ -405,7 +405,7 @@ Attribute: :ada:`Digits` :ada:`Digits` is an attribute that returns the requested decimal precision of a floating-point subtype. Let's see an example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Digits +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Digits with Ada.Text_IO; use Ada.Text_IO; @@ -425,7 +425,7 @@ Note that we said that :ada:`Digits` is the *requested* level of precision, which is specified as part of declaring a floating point type. We can retrieve the actual decimal precision with :ada:`Base'Digits`. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Base_Digits +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Base_Digits with Ada.Text_IO; use Ada.Text_IO; @@ -462,7 +462,7 @@ indicating whether a feature is available or not in the target architecture: :ada:`Constraint_Error` exception is (or is not) guaranteed to be raised when an operation with that type produces an overflow or divide-by-zero. -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Machine_Rounds_Overflows +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Machine_Rounds_Overflows with Ada.Text_IO; use Ada.Text_IO; @@ -541,7 +541,7 @@ floating-point value: Let's see some examples: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Exponent_Fraction +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Exponent_Fraction with Ada.Text_IO; use Ada.Text_IO; @@ -600,7 +600,7 @@ Attribute: :ada:`Scaling` :ada:`Scaling` is an attribute that scales a floating-point value based on the machine radix and a machine exponent passed to the function. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Scaling +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Scaling with Ada.Text_IO; use Ada.Text_IO; @@ -629,7 +629,7 @@ Round-up and round-down attributes :ada:`Floor` and :ada:`Ceiling` are attributes that returned the rounded-down or rounded-up value, respectively, of a floating-point value. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Floor_Ceiling +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Floor_Ceiling with Ada.Text_IO; use Ada.Text_IO; @@ -655,7 +655,7 @@ is the closest integer value. Let's see a code example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Rounding +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Rounding with Ada.Text_IO; use Ada.Text_IO; @@ -752,7 +752,7 @@ second parameter is the :ada:`Towards` value. Let's see a code example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Truncation_Remainder +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Truncation_Remainder with Ada.Text_IO; use Ada.Text_IO; @@ -837,7 +837,7 @@ mantissa. Let's see some examples: Let's see some examples: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Sign_Leading +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Sign_Leading with Ada.Text_IO; use Ada.Text_IO; @@ -879,7 +879,7 @@ Not every real number is directly representable as a floating-point value on a specific machine. For example, let's take a value such as 1.0 x 10\ :sup:`15` (or 1,000,000,000,000,000): -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Float_Value +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Float_Value with Ada.Text_IO; use Ada.Text_IO; @@ -932,7 +932,7 @@ the difference between the original real value in our example (1.0 x 10\ :sup:`15`) and the actual value that is assigned to :ada:`V`. We can do this by using the :ada:`Machine` attribute in the calculation: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Machine_Attribute +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Machine_Attribute with Ada.Text_IO; use Ada.Text_IO; @@ -1028,7 +1028,7 @@ This is the reason why we see 1.3008896 x 10\ :sup:`7` instead of Let's see an example: - .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Model_Mantissa + .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Model_Mantissa with Ada.Text_IO; use Ada.Text_IO; @@ -1075,7 +1075,7 @@ This is the reason why we see 1.3008896 x 10\ :sup:`7` instead of Let's see some examples: - .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Model_Epsilon_Small + .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Model_Epsilon_Small with Ada.Text_IO; use Ada.Text_IO; @@ -1118,7 +1118,7 @@ This is the reason why we see 1.3008896 x 10\ :sup:`7` instead of value in 1.0 x 10\ :sup:`15` and the actual model value, we can use the :ada:`Model` attribute: - .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Model_Attribute + .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Model_Attribute with Ada.Text_IO; use Ada.Text_IO; @@ -1169,7 +1169,7 @@ This is the reason why we see 1.3008896 x 10\ :sup:`7` instead of Let's see a code example with these attributes and compare them to the :ada:`First` and :ada:`Last` attributes: - .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Safe_First_Last + .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Floating_Point_Types.Safe_First_Last with Ada.Text_IO; use Ada.Text_IO; @@ -1229,7 +1229,7 @@ Attribute: :ada:`Machine_Radix` :ada:`Machine_Radix` is an attribute that returns the radix of the hardware representation of a type. For example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Fixed_Machine_Radix +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Fixed_Machine_Radix with Ada.Text_IO; use Ada.Text_IO; @@ -1265,7 +1265,7 @@ indicating whether a feature is available or not in the target architecture: :ada:`Constraint_Error` is guaranteed to be raised when a fixed-point operation with that type produces an overflow or divide-by-zero. -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Fixed_Machine_Rounds_Overflows +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Fixed_Machine_Rounds_Overflows with Ada.Text_IO; use Ada.Text_IO; @@ -1314,7 +1314,7 @@ it's automatically selected by the compiler, and it's always equal to the Let's see an example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Fixed_Small_Delta +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Fixed_Small_Delta package Fixed_Small_Delta is D3 : constant := 10.0 ** (-3); @@ -1386,7 +1386,7 @@ In the case of the :ada:`TQ15` type, we're specifying the *small* by using the type is 32 bits, while the precision we get when operating with this type is 16 bits. Let's see a specific example for this type: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Fixed_Small_Delta +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Fixed_Small_Delta with Ada.Text_IO; use Ada.Text_IO; @@ -1431,7 +1431,7 @@ precise: Let's see an example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Fixed_Fore_Aft +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Fixed_Fore_Aft with Ada.Text_IO; use Ada.Text_IO; @@ -1485,7 +1485,7 @@ use for the :ada:`digits` in the definition of a decimal fixed-point type. Let's see an example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Decimal_Digits +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Decimal_Digits with Ada.Text_IO; use Ada.Text_IO; @@ -1527,7 +1527,7 @@ of :ada:`T'Scale` is three. Let's look at this complete example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Decimal_Scale +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Decimal_Scale with Ada.Text_IO; use Ada.Text_IO; @@ -1570,7 +1570,7 @@ value, while the returned value is of :ada:`S'Base` type. Let's look at this example: -.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Decimal_Round +.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numeric_Attributes.Fixed_Point_Types.Decimal_Round with Ada.Text_IO; use Ada.Text_IO; From fa0fb2936084483d7acb11cf512ab6279ea9975d Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:01:13 +0100 Subject: [PATCH 03/10] Editorial change: moving code to Custom_Floating_Point_Types package --- .../advanced-ada/parts/data_types/numerics.rst | 13 ++++++++++--- 1 file changed, 10 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 d80c58a4f..f9737d6a7 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -2463,9 +2463,7 @@ still select a 32-bit floating-point type for the target platform. For example: .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Floating_Point_Types.Floating_Point_Decimal_Precision - with Ada.Text_IO; use Ada.Text_IO; - - procedure Show_Decimal_Digits is + package Custom_Floating_Point_Types is type Float_1_Digits is digits 1; @@ -2503,6 +2501,15 @@ still select a 32-bit floating-point type for the target platform. For example: digits 17; type Float_18_Digits is digits 18; + + end Custom_Floating_Point_Types; + + with Ada.Text_IO; use Ada.Text_IO; + + with Custom_Floating_Point_Types; + use Custom_Floating_Point_Types; + + procedure Show_Decimal_Digits is begin Put_Line ("Float_1_Digits'Size :" & Float_1_Digits'Size'Image From 36e8b55e8fcb1560ba2ea8892f89b44c958680a5 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:01:26 +0100 Subject: [PATCH 04/10] Minor editorial change --- 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 f9737d6a7..a78159106 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -2315,7 +2315,7 @@ As expected, we can derive from any floating-point type. For example: with Ada.Text_IO; use Ada.Text_IO; with Custom_Floating_Point_Types; - use Custom_Floating_Point_Types; + use Custom_Floating_Point_Types; procedure Show_Derived_Floating_Point_Types is C : Coefficient; From d68b2806fcd4adba86cb92b37251d6929b5f0237 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:02:08 +0100 Subject: [PATCH 05/10] Adding small note on size of base types --- content/courses/advanced-ada/parts/data_types/numerics.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index a78159106..fb9b03764 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -2584,6 +2584,10 @@ floating-point data types on the target hardware. However, as you might recall from an earlier chapter, we can request specific sizes for custom types. We discuss this topic next. +Note that, for the example above, the size of the type is equal to the size of +its base type, i.e. :ada:`Float_1_Digits'Size = Float_1_Digits'Base'Size`, +:ada:`Float_2_Digits'Size = Float_2_Digits'Base'Size`, and so on. + .. _Adv_Ada_Floating_Point_Type_Size: From 38eb77044c8f5f5dfd89c2371541e462a3d372d8 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:02:41 +0100 Subject: [PATCH 06/10] Editorial change: adding todo item --- content/courses/advanced-ada/parts/data_types/numerics.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/content/courses/advanced-ada/parts/data_types/numerics.rst b/content/courses/advanced-ada/parts/data_types/numerics.rst index fb9b03764..0e6b9b987 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -2624,6 +2624,9 @@ bits to be represented |mdash| instead of the 32 bits that we would typically see on a desktop PC. (Also, remember that this code example won't compile if your target architecture doesn't support 128-bit floating-point data types.) +.. todo:: + + Discuss :ada:`Float_6_Digits'Size` vs. :ada:`Float_6_Digits'Base'Size`. Range of custom floating-point types and subtypes From b945bdd298ac795bc0a97a9f55610945039a4b6d Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:03:02 +0100 Subject: [PATCH 07/10] Editorial change: correcting grammar --- 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 0e6b9b987..5bce2349c 100644 --- a/content/courses/advanced-ada/parts/data_types/numerics.rst +++ b/content/courses/advanced-ada/parts/data_types/numerics.rst @@ -785,7 +785,7 @@ In this example, we get a compilation error because the range of the .. admonition:: For further reading... To circumvent the compilation error in the code example we've just seen, - the best alternative to use :ref:`big numbers ` + the best alternative is to use :ref:`big numbers ` |mdash| we discuss this topic later on in this chapter: .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Universal_Numeric_Types.Conversion_To_Non_Universal_Types switches=Compiler(-gnat2022); From dbaea307ef5d8ba858af7b2e11851ed73fcfd57d Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:04:59 +0100 Subject: [PATCH 08/10] Editorial change: using commas for number --- .../advanced-ada/parts/data_types/numeric_attributes.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst b/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst index f0a47d57f..6ffe671aa 100644 --- a/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst +++ b/content/courses/advanced-ada/parts/data_types/numeric_attributes.rst @@ -43,7 +43,8 @@ chapter: Put_Line (Modulus_Value'Image); end Show_Modular; -When we run this example, we get 4294967296, which is equal to :ada:`2**32`. +When we run this example, we get 4,294,967,296 |mdash| which is equal to +:ada:`2**32`. :ada:`Mod` Attribute ~~~~~~~~~~~~~~~~~~~~ From 7b43053838ce7888e8f9b125939ba3ed3ebc8416 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:13:23 +0100 Subject: [PATCH 09/10] Editorial change: using commas for number --- .../advanced-ada/parts/data_types/types_representation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/courses/advanced-ada/parts/data_types/types_representation.rst b/content/courses/advanced-ada/parts/data_types/types_representation.rst index 0c3f93fee..6e018ace1 100644 --- a/content/courses/advanced-ada/parts/data_types/types_representation.rst +++ b/content/courses/advanced-ada/parts/data_types/types_representation.rst @@ -428,7 +428,7 @@ well as with actual objects of that data type. Therefore, we can write :ada:`UInt_7_Array'Component_Size` and :ada:`Arr_1'Component_Size`, for example. -This big number (17179869176 bits) for :ada:`UInt_7_Array'Size` and +This big number (17,179,869,176 bits) for :ada:`UInt_7_Array'Size` and :ada:`UInt_7_Array'Object_Size` might be surprising for you. This is due to the fact that Ada is reporting the size of the :ada:`UInt_7_Array` type for the case when the complete range is used. Considering that we specified a positive From 3b17528701744a4e4f06cbf16220be25d95bec4b Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 31 Oct 2025 23:14:47 +0100 Subject: [PATCH 10/10] Editorial change: correcting number Correcting issue reported by reader (T. Ishmuratov) --- .../advanced-ada/parts/data_types/types_representation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/courses/advanced-ada/parts/data_types/types_representation.rst b/content/courses/advanced-ada/parts/data_types/types_representation.rst index 6e018ace1..718dd96a7 100644 --- a/content/courses/advanced-ada/parts/data_types/types_representation.rst +++ b/content/courses/advanced-ada/parts/data_types/types_representation.rst @@ -1403,7 +1403,7 @@ This is the code that implements that: When running the application above, we see that, due to the extra byte in the record representation, the sizes increase. On a typical 64-bit PC, -:ada:`R'Size` is now 76 bits, which reflects the additional eight bits that we +:ada:`R'Size` is now 72 bits, which reflects the additional eight bits that we introduced between components :ada:`A` and :ada:`B`. Depending on the target architecture, you may also see that :ada:`R'Object_Size` is now 96 bits, which is the size the compiler selects as the most appropriate for this record type.