@@ -3113,8 +3113,11 @@ target machine.
31133113
31143114The *small * must be at least equal to or smaller than the *delta *. In many
31153115cases, however, the *small * of a type :ada: `T ` is equal to the *delta * of that
3116- type. In addition, note that these values aren't necessarily small numbers
3117- |mdash | in fact, they could be quite large.
3116+ type. In addition, for decimal fixed-point types specifically, the *small * is
3117+ **always ** equal to its *delta *.
3118+
3119+ Note that *small * of a type isn't necessarily a small number |mdash | in fact,
3120+ it could be quite large. We'll see examples of that later on in this chapter.
31183121
31193122We can use the :ada: `T'Small ` and :ada: `T'Delta ` attributes to retrieve the
31203123actual values of the *small * and *delta * of a fixed-point type :ada: `T `. (We
@@ -3338,17 +3341,17 @@ Let's see an example using a decimal fixed-point type:
33383341
33393342 procedure Show_Custom_Size_Decimal is
33403343
3341- type Decimal_6_Digits is
3344+ type Decimal_128_Bits is
33423345 delta 10.0 ** (-2) digits 6
33433346 with Size => 128;
33443347
33453348 begin
3346- Put_Line ("Decimal_6_Digits 'Size :"
3347- & Decimal_6_Digits 'Size'Image
3349+ Put_Line ("Decimal_128_Bits 'Size :"
3350+ & Decimal_128_Bits 'Size'Image
33483351 & " bits");
33493352 end Show_Custom_Size_Decimal;
33503353
3351- In this example, we require that :ada: `Decimal_6_Digits ` has a size of 128
3354+ In this example, we require that :ada: `Decimal_128_Bits ` has a size of 128
33523355bits on the target platform |mdash | instead of the 32 bits that we would
33533356typically see for that type on a desktop PC. (As a reminder, this code example
33543357won't compile if your target architecture doesn't support 128-bit data types.)
@@ -3359,10 +3362,11 @@ won't compile if your target architecture doesn't support 128-bit data types.)
33593362Machine representation of fixed-point types
33603363~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33613364
3362- In this section, we discuss how fixed-point types are typically
3363- represented in actual hardware. For that, we can use
3364- :ref: `overlays <Adv_Ada_Address_Aspect_Overlay >` to retrieve the actual integer
3365- representation on the machine of objects of the fixed-point type.
3365+ In this section, we discuss how fixed-point types are represented in actual
3366+ hardware. Typically, the machine representation of objects of fixed-point type
3367+ consists of integer values implicitly scaled by the *small * of the type. To
3368+ retrieve the actual integer representation, we can use
3369+ :ref: `overlays <Adv_Ada_Address_Aspect_Overlay >`.
33663370
33673371
33683372.. _Adv_Ada_Decimal_Fixed_Point_Machine_Representation :
@@ -3457,11 +3461,11 @@ machine when assigning values to objects of decimal type. For example:
34573461 Put_Line ("-----------------------------");
34583462 end Show_Machine_Implementation;
34593463
3460- In this example, we use the overlays :ada: `Int_T0_D4 ` and :ada: `Int_T2_D6 ` to
3461- retrieve the integer representation of the decimal fixed-point types
3462- :ada: ` T0_D4 ` and :ada: `T2_D6 `. In the output of this example , we might see the
3463- following integer representation of the real values for the :ada: `T0_D4 ` and
3464- :ada: ` T2_D6 ` types :
3464+ In this example, we use the overlays :ada: `V_Int_T0_D4 ` and :ada: `V_Int_T2_D6 `
3465+ to retrieve the integer representation of the decimal variables :ada: ` V_T0_D4 `
3466+ and :ada: `V_T2_D6 `. By doing this, we retrieve the machine representation of
3467+ the real values for the :ada: `T0_D4 ` and :ada: ` T2_D6 ` types. The table shows
3468+ the values that we get by running the test application :
34653469
34663470+-------------+-----------------------------+
34673471| Real value | Integer representation |
@@ -3482,15 +3486,20 @@ types on the target machine.
34823486
34833487The scalefactor is 1 (or 10\ :sup: `0`) for the :ada: `T0_D4 ` type and 0.01
34843488(or 10\ :sup: `-2`) for the :ada: `T2_D6 ` type. As you have might have noticed,
3485- this scalefactor corresponds to the *delta * we've used in the type declaration.
3489+ this scalefactor is equal to the *delta * we've used in the type declaration.
3490+ In actuality, however, the scalefactor is the *small * of the type |mdash |
3491+ which, as we've seen before, is equal to the *delta * for decimal fixed-point
3492+ types. (Later on, we see that this *detail * makes a difference for ordinary
3493+ fixed-point types.)
3494+
34863495For example, if we multiple the integer representation of the real value by the
3487- *delta *, we get the real value:
3496+ *small *, we get the real value:
34883497
34893498+-------------+-------------------------------+
3490- | Real value | :ada: `T2_D6 ` |
3499+ | Real value | :ada: `T2_D6 ` type |
34913500| +-------------------------------+
34923501| | Integer representation |
3493- | | multiplied by * delta * |
3502+ | | multiplied by the * small * |
34943503+=============+===============================+
34953504| 1.00 | = 100 * 0.01 |
34963505+-------------+-------------------------------+
0 commit comments