Skip to content

Commit 0616ac5

Browse files
authored
Merge pull request #1294 from gusthoff/content/advanced_ada/review/numerics/fixed_point_types/20251219
Review of section about fixed-point types
2 parents c4df164 + e8b52b5 commit 0616ac5

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

content/courses/advanced-ada/parts/data_types/numerics.rst

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ are universal fixed types.
973973

974974
It's possible to implement custom :ada:`*` and :ada:`/` operators for
975975
fixed-point types. However, those operators do **not** override the
976-
corresponding operators for universal fixed-point types. For example:
976+
corresponding operators for universal fixed types. For example:
977977

978978
.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Universal_Types.Fixed_Point_Custom_Multiplication
979979

@@ -1060,7 +1060,7 @@ are universal fixed types.
10601060
operator, we're indeed overriding the default :ada:`+` operator of the
10611061
:ada:`TQ31` type in the :ada:`Normalized_Fixed_Point_Types` because the
10621062
addition operator is associated with its corresponding fixed-point type,
1063-
not with the universal fixed-point type. In the
1063+
not with the universal fixed type. In the
10641064
:ada:`Q31_A := Q31_A * Q31_B` statement, we see at runtime (through the
10651065
"=> Custom non-overriding '*'" message) that the custom
10661066
multiplication is being used.
@@ -3140,13 +3140,20 @@ In this example, we see the values for the compiler-selected *small* and the
31403140
*delta* of type :ada:`Ordinary_Fixed_Point`. (Both are 0.25.)
31413141

31423142
When we declare a fixed-point data type, we must specify the *delta*. In
3143-
contrast, providing a *small* in the type declaration is optional.
3143+
contrast, providing a *small* in the type declaration is optional for
3144+
ordinary fixed-point data types, but forbidden for decimal fixed-point types.
31443145

3145-
When the *small* isn't specified, it is automatically selected by the compiler.
3146-
In this case, the actual value of the *small* is an implementation-defined
3146+
By default, the compiler automatically selects the *small*: this value is a
31473147
power of ten for decimal fixed-point types and a power of two for ordinary
3148-
fixed-point types. Again, the selected value always follows the rule that the
3149-
*small* must be smaller or equal to the delta. For example:
3148+
fixed-point types. Also, for ordinary fixed-point types, we can specify the
3149+
*small* by using the :ada:`Small` aspect.
3150+
3151+
.. todo::
3152+
3153+
Add link to subsection on :ada:`Small` aspect once available.
3154+
3155+
As we mentioned before, the selected value for the *small* always follows the
3156+
rule that it must be smaller or equal to the *delta*. For example:
31503157

31513158
.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Fixed_Small_Delta
31523159

@@ -3170,17 +3177,6 @@ fixed-point types. Again, the selected value always follows the rule that the
31703177
In this example, the *delta* that we specifed for :ada:`Ordinary_Fixed_Point`
31713178
is 0.2, while the compiler-selected *small* is 2.0\ :sup:`-3`.
31723179

3173-
If we want to specify the *small*, we can use the :ada:`Small` aspect. (we'll
3174-
see this aspect again later on.)
3175-
3176-
.. todo::
3177-
3178-
Add link to subsection on :ada:`Small` aspect once available.
3179-
3180-
However, we can only do so for ordinary fixed-point types: for decimal
3181-
fixed-point types, the *small* is automatically selected by the compiler, and
3182-
it's always equal to the *delta*.
3183-
31843180
.. admonition:: For further reading...
31853181

31863182
As we've mentioned, the small and the delta need not actually be small

0 commit comments

Comments
 (0)