ada Outputting numbers Print integers, generously using space


Example

Instances of Integer_IO have a settings variable Default_Width which the number of characters that each output number will take.

with Ada.Text_IO;   use Ada.Text_IO;

procedure Print_Integer is
    subtype Count is Integer range -1_000_000 .. 1_000_000;

    package Count_IO is new Integer_IO (Count);
    X : Count;
begin
    Count_IO.Default_Width := 12;

    X := Count'First;
    while X < Count'Last loop
        Count_IO.Put (X);
        Count_IO.Put (X + 1);
        New_Line;

        X := X + 500_000;
    end loop;
end Print_Integer;

Result

    -1000000
     -500000
           0
      500000