Skip to content

Conversation

@gusthoff
Copy link
Collaborator

No description provided.

@gusthoff gusthoff added the new section Section using new content label Dec 14, 2025
@gusthoff gusthoff requested review from swbaird and removed request for brosgol and pat-rogers January 9, 2026 20:22
Copy link

@swbaird swbaird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff! I raised a few points.

integer types to emulate fixed-point operations.

As mentioned in the Introduction to Ada course course, fixed-point types
are classified in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "are classified as either blah or blah". This use of "in" seems odd.

the compiler to derive a range.

.. code-block:: ada
Note that, unlike floating-point types, there are no predefined decimal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "unlike floating-point types and ordinary fixed-point types" ? Feel free to ignore this suggestion.

zero. For example:

.. code:: ada run_button project=Courses.Intro_To_Ada.Fixed_Point_Types.Decimal_Fixed_Point_Smaller
The *delta* is a scaling factor (a power of ten) that allows developers to
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be useful to mention here the fact that delta = small for a decimal fixed point type (unlike the case of an ordinary fixed point type)? I think that would be worth noting somewhere in this document (perhaps not here).


with Ada.Text_IO; use Ada.Text_IO;
Let's look at a small, practical example showing the conversion between two
currencies |mdash| in this case, between euros and yens:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plural of "yen" is "yen", not "yens".


-- Exchange rates as of
-- 2025-12-26:
EUR_Yen : constant := 184.365_5;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps EUR_Per_Yen and Yen_Per_EUR ?

floating-point type :ada:`TD18`. Conversion between these two types works as
expected: we use :ada:`TD18 (D6)` to convert from a decimal fixed-point type
and :ada:`T2_D6 (D18)` to convert to a decimal fixed-point type. Of course,
when converting to a decimal fixed-point type, we have to ensure that the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are talking about two forms of conversions (both float-to-decimal-fixed and the reverse) and, having established that context, we then make it sound like a range check on the result is only performed in one of the two cases. That seems at least confusing. Consider
type Flo is new Float range 0.0 .. 1234.5;
type Dfx is delta 1.0 digits 5;
Dfx_Obj : Dft := -1.0;
Flo_Obj : Flo := Flo (Dfx_Obj); -- fails range check

& Max_Delta'Image);
end Show_Min_Max_Scale;

On a desktop PC, you may see that the :ada:`Min_Scale` is -38, while the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps "On a 64-bit desktop PC"?

& Max_Decimal_Digits'Image);
end Show_Max_Decimal_Digits;

On a typical desktop PC, we may see that the value of :ada:`Max_Decimal_Digits`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for previous "desktop PC" reference.


.. admonition:: For further reading...

The :ada:`Digits` attribute gives us the number of significant decimal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere in this document, it might be worth mentioning that attributes like Digits, Delta, and Scale can be usefully applied to a generic formal decimal fixed point type. They are not just for retrieving information that could be obtained equally well (at the cost of some redundancy in the code) by looking at the type declaration. Or perhaps such formal types are beyond the scope of this document?


In this example, the :ada:`Max_Fin_Decimal` type uses a delta of 0.01 and the
number of significant decimal digits based on the value of
:ada:`Max_Decimal_Digits`. On a typical desktop PC, this gives us (almost) a
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same "desktop PC" comment as before - if I encounter "desktop PC" again later in this review, I won't bother flagging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new section Section using new content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants