This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Problem with GNAT Ada floating-point image representation under HPUX
- From: "Clarke, Carus V" <carus dot v dot clarke at pss dot Boeing dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Thu, 20 Oct 2005 14:36:09 -0700
- Subject: Problem with GNAT Ada floating-point image representation under HPUX
I have been using the gcc 3.4.4 GNAT compiler to compile an existing Ada
program on an HP-UX 11 system.
We have noticed that generated images of floating-point numbers often
appear with the least-significant digit incremented by 1. Since the
application is used in a calibration laboratory, this situation is not
acceptable to the users. Below is some sample output, followed by a
listing of the program that produced the output. This same program
produces the expected output when compiled and run on a Windows machine,
that uses the same revision (3.4.4 -- cygming special) of the compiler.
The program also produces the expected output when compiled with the
older GNAT-3.15p compiler on the HP-UX machine. Using gdb 6.3 to step
through the program as it was running on the HP-UX machine showed that
the Value attribute did correctly convert the string representation
("1.0000") to 1.0 for both Float and Long_Float cases.
The build configuration for the compiler is:
Reading specs from
/site/sw/gcc-3.4.4/lib/gcc/hppa2.0w-hp-hpux11.11/3.4.4/specs
Configured with: ../gcc-3.4.4/configure --prefix=/site/sw/gcc-3.4.4
--with-gnu-as --with-as=/site/sw/gcc-3.4.4/bin/as --disable-nls
--enable-languages=c,c++,ada --enable-threads=gnat
Thread model: gnat
gcc version 3.4.4
And the as version is:
GNU assembler version 2.15 (hppa2.0w-hp-hpux11.11) using BFD version
2.15
I have also noted the same behavior with the gcc 4.0 GNAT compiler.
Any suggestions or ideas would be appreciated.
Thanks,
Carus V. (Bud) Clarke
carus.v.clarke@boeing.com
------------------------------------------------------------------------
------------------
Program output:
The number's string representation is: 1.0000
The image of the float value is: 1.00001E+00
Text_Io output for float value is: 1.00001
The image of the long-float value is: 1.00000000000001E+00
Text_Io output for long-float value is: 1.0000001
------------------------------------------------------------------------
------------------
Program code:
------------------------------------------------------------------------
-- File: test_float_image.adb
-- Date: Oct. 20, 2005
------------------------------------------------------------------------
with Ada.Text_Io;
with Ada.Float_Text_Io;
with Ada.Long_Float_Text_Io;
procedure Test_Float_Image is
XSTR : constant String := "1.0000";
XF : constant Float := Float'Value(XSTR);
XL : constant Long_Float := Long_Float'Value(XSTR);
begin
Ada.Text_Io.Put ("The number's string representation is: ");
Ada.Text_Io.Put (XSTR);
Ada.Text_Io.New_Line;
Ada.Text_Io.Put ("The image of the float value is: ");
Ada.Text_Io.Put (Float'Image(XF));
Ada.Text_Io.New_Line;
Ada.Text_Io.Put ("Text_Io output for float value is: ");
Ada.Float_Text_Io.Put (Item => XF,
Fore => 4,
Aft => 5,
Exp => 0);
Ada.Text_Io.New_Line;
Ada.Text_Io.Put ("The image of the long-float value is: ");
Ada.Text_Io.Put (Long_Float'Image(XL));
Ada.Text_Io.New_Line;
Ada.Text_Io.Put ("Text_Io output for long-float value is: ");
Ada.Long_Float_Text_Io.Put (Item => XL,
Fore => 4,
Aft => 7,
Exp => 0);
Ada.Text_Io.New_Line;
end Test_Float_Image;
------------------------------------------------------------------------
------------------