comp.lang.ada
 help / color / mirror / Atom feed
* Oddity with function returning image of fixed point type
@ 2021-09-02 10:25 Jesper Quorning
  2021-09-02 17:08 ` Stephen Leake
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Quorning @ 2021-09-02 10:25 UTC (permalink / raw)


Is something odd going on here?
I did not expect Image_Odd1/2 to return floating point images.


with Ada.Text_Io;     use Ada.Text_Io;

procedure Fpt_Last is

   type Fpt is delta 0.01 digits 4;

   Image_Last : constant String := Fpt'Image (Fpt'Last);

   function Image_Ok return String is
   begin
      return Fpt'Last'Image;
      --  return Fpt'Image (Fpt'Last); -- Also ok
   end Image_Ok;

   Last : constant Fpt := Fpt'Last;

   function Image_Odd_1 return String is (Fpt'Last'Img);
   function Image_Odd_2 return String is (Fpt'Last'Image);
   function Image_Ok_2  return String is (Fpt'Image (FPT'Last));
   function Image_Ok_3  return String is (Last'Image);

begin
   Put_Line ("Image_Last  : " & Image_Last);
   Put_Line ("Image_Ok    : " & Image_Ok);
   Put_Line ("Image_Odd_1 : " & Image_Odd_1);
   Put_Line ("Image_Odd_2 : " & Image_Odd_2);
   Put_Line ("Image_Ok_2  : " & Image_Ok_2);
   Put_Line ("Image_Ok_3  : " & Image_Ok_3);
end Fpt_Last;


Output:

Image_Last  :  99.99
Image_Ok    :  99.99
Image_Odd_1 :  9.99900000000000000E+01
Image_Odd_2 :  9.99900000000000000E+01
Image_Ok_2  :  99.99
Image_Ok_3  :  99.99

Compiled with gnatmake version 10.3.0 or CE 2020 on macOS 10.13.6.


/Jesper

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-02 23:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 10:25 Oddity with function returning image of fixed point type Jesper Quorning
2021-09-02 17:08 ` Stephen Leake
2021-09-02 17:32   ` Dmitry A. Kazakov
2021-09-02 23:24     ` Jesper Quorning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox