home *** CD-ROM | disk | FTP | other *** search
/ Hacker / Hacker.iso / HACKER / DECOMP / DECAF / cpfloats.adb < prev    next >
Encoding:
Text File  |  1996-09-19  |  1.6 KB  |  53 lines

  1. --
  2. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  3. -- Author: Gilles Demailly
  4. --
  5. --
  6. -- Permission to use, copy, modify, and distribute this software and its
  7. -- documentation for any purpose and without fee is hereby granted,
  8. -- provided that the above copyright and authorship notice appear in all
  9. -- copies and that both that copyright notice and this permission notice
  10. -- appear in supporting documentation.
  11. -- 
  12. -- The ARA makes no representations about the suitability of this software
  13. -- for any purpose.  It is provided "as is" without express
  14. -- or implied warranty.
  15. -- 
  16.  
  17. with Ada.Text_Io;
  18.  
  19. with Float_32_Io;
  20.  
  21. package body CP.Floats is
  22.  
  23.    use Byte_Utilities;
  24.  
  25.    procedure Decode (From_File : Byte_Utilities.File_Type;
  26.                      Some_Info : access Floats) is
  27.    begin
  28.       Some_Info.Tag := C_Class_Tag;
  29.  
  30.       -- Reads the float value
  31.       ------------------------
  32.       Read (From_File, Some_Info.Float_Value);
  33.    end Decode;
  34.  
  35.    procedure Display (Some_Info : access Floats;
  36.                       Context   : in Acc_CP_Infos) is
  37.    begin
  38.       -- the two tests are necessary because Float_32_Io could not
  39.       -- handle Infinity values (+ and -) when I did test it
  40.       -- with the Java class Float, my executable went to an
  41.       -- infinite loop.
  42.       ------------------------------------------------------------
  43.       if Some_Info.Float_Value >= Float_32'Last then
  44.          Ada.Text_Io.Put ("Inf");
  45.       elsif Some_Info.Float_Value <= Float_32'First then
  46.          Ada.Text_Io.Put ("-Inf");
  47.       else
  48.          Float_32_Io.Put (Some_Info.Float_Value);
  49.       end if;
  50.    end Display;
  51.    
  52. end CP.Floats;
  53.