Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions content/courses/advanced-ada/parts/data_types/numerics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ are universal fixed types.

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

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

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

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

When the *small* isn't specified, it is automatically selected by the compiler.
In this case, the actual value of the *small* is an implementation-defined
By default, the compiler automatically selects the *small*: this value is a
power of ten for decimal fixed-point types and a power of two for ordinary
fixed-point types. Again, the selected value always follows the rule that the
*small* must be smaller or equal to the delta. For example:
fixed-point types. Also, for ordinary fixed-point types, we can specify the
*small* by using the :ada:`Small` aspect.

.. todo::

Add link to subsection on :ada:`Small` aspect once available.

As we mentioned before, the selected value for the *small* always follows the
rule that it must be smaller or equal to the *delta*. For example:

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

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

If we want to specify the *small*, we can use the :ada:`Small` aspect. (we'll
see this aspect again later on.)

.. todo::

Add link to subsection on :ada:`Small` aspect once available.

However, we can only do so for ordinary fixed-point types: for decimal
fixed-point types, the *small* is automatically selected by the compiler, and
it's always equal to the *delta*.

.. admonition:: For further reading...

As we've mentioned, the small and the delta need not actually be small
Expand Down
Loading