8.L.F. Float - JulTob/Ada GitHub Wiki

with ada.text_io, ada.float_text_io;
use ada.text_io, ada.float_text_io;

procedure rounding is
  -- rounding example

  procedure ShowRounding( f : float ) is
    -- show the floating point value, and show the value
    -- after it's converted to an integer
    int_value : integer;
    begin
      Put( "  Float number " );
      Put( f, fore => 5, aft => 3 );
      int_value := integer( f );
      Put_Line( " rounds to " & int_value'img );
      end ShowRounding;

  begin
   Put_Line( "This is a demonstration of how Ada 95 rounds" );
   New_Line;

   ShowRounding( 253.0 );
   ShowRounding( 253.2 );
   ShowRounding( 253.5 );
   ShowRounding( 253.8 );
   ShowRounding( -253.8 );

   end rounding;