home *** CD-ROM | disk | FTP | other *** search
- --
- -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
- -- Author: Gilles Demailly
- --
- --
- -- Permission to use, copy, modify, and distribute this software and its
- -- documentation for any purpose and without fee is hereby granted,
- -- provided that the above copyright and authorship notice appear in all
- -- copies and that both that copyright notice and this permission notice
- -- appear in supporting documentation.
- --
- -- The ARA makes no representations about the suitability of this software
- -- for any purpose. It is provided "as is" without express
- -- or implied warranty.
- --
-
- with Ada.Text_Io;
-
- with Float_32_Io;
-
- package body CP.Floats is
-
- use Byte_Utilities;
-
- procedure Decode (From_File : Byte_Utilities.File_Type;
- Some_Info : access Floats) is
- begin
- Some_Info.Tag := C_Class_Tag;
-
- -- Reads the float value
- ------------------------
- Read (From_File, Some_Info.Float_Value);
- end Decode;
-
- procedure Display (Some_Info : access Floats;
- Context : in Acc_CP_Infos) is
- begin
- -- the two tests are necessary because Float_32_Io could not
- -- handle Infinity values (+ and -) when I did test it
- -- with the Java class Float, my executable went to an
- -- infinite loop.
- ------------------------------------------------------------
- if Some_Info.Float_Value >= Float_32'Last then
- Ada.Text_Io.Put ("Inf");
- elsif Some_Info.Float_Value <= Float_32'First then
- Ada.Text_Io.Put ("-Inf");
- else
- Float_32_Io.Put (Some_Info.Float_Value);
- end if;
- end Display;
-
- end CP.Floats;
-