@@ -4605,60 +4605,6 @@ when assigning the result to an object of a different type. As we've mentioned
46054605before, type conversions between fixed-point types make use of universal
46064606fixed-point types.
46074607
4608- .. ::
4609-
4610- Consider the following package from a previous section:
4611-
4612- .. code:: ada compile_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Universal_Fixed_2
4613-
4614- package Custom_Decimal_Types is
4615-
4616- type Short_Decimal is
4617- delta 10.0 ** (-0) digits 4;
4618- -- range -9_999.0 .. 9_999.0;
4619-
4620- type Decimal is
4621- delta 10.0 ** (-2) digits 6;
4622- -- range -9_999.99 .. 9_999.99;
4623-
4624- end Custom_Decimal_Types;
4625-
4626- Let's look at a simple example of type conversions between these types:
4627-
4628- .. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Fixed_Point_Types.Universal_Fixed_2
4629-
4630- with Ada.Text_IO; use Ada.Text_IO;
4631-
4632- with Custom_Decimal_Types;
4633- use Custom_Decimal_Types;
4634-
4635- procedure Show_Mixing_Decimal_Types is
4636- A : Short_Decimal;
4637- B : Decimal;
4638- begin
4639- A := Short_Decimal'Last; -- 9_999.0
4640- B := Decimal (A);
4641- Put_Line ("A = " &
4642- A'Image);
4643- Put_Line ("B = A = " &
4644- B'Image);
4645-
4646- Put_Line ("--------------");
4647- B := 9_999.0;
4648- A := Short_Decimal (B);
4649- Put_Line ("B = " &
4650- B'Image);
4651- Put_Line ("A = B = " &
4652- A'Image);
4653-
4654- end Show_Mixing_Decimal_Types;
4655-
4656- Here, we use :ada:`Decimal (A)` and :ada:`Short_Decimal (B)` to convert to :ada:`Decimal`
4657- and :ada:`Short_Decimal`, respectively.
4658-
4659- Note that, if we had assigned :ada:`9_999.99` (or :ada:`Decimal`) to :ada:`B` in
4660- the code above, the :ada:`Short_Decimal (B)` would raise a :ada:`Constraint_Error`
4661- exception due the small difference in the range that we mentioned previously.
46624608
46634609Multiplication and division operations with decimal types
46644610^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments