From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:ac8:7761:: with SMTP id h1mr2266993qtu.272.1630578345547; Thu, 02 Sep 2021 03:25:45 -0700 (PDT) X-Received: by 2002:a25:afcd:: with SMTP id d13mr3359595ybj.504.1630578345330; Thu, 02 Sep 2021 03:25:45 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 2 Sep 2021 03:25:45 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=194.255.97.108; posting-account=hMbstgoAAAAIa4kxFYtvUVUHbE1RcZzT NNTP-Posting-Host: 194.255.97.108 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Oddity with function returning image of fixed point type From: Jesper Quorning Injection-Date: Thu, 02 Sep 2021 10:25:45 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:62604 List-Id: 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