ada Outputting numbers Print Integers, Using Base 16 (Hexadecimal)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

A settings variable Default_Base is set on the instance of Ada.Text_IO.Integer_IO; also, Default_Width is set so that output cannot have leading space.

with Ada.Text_IO;   use Ada.Text_IO;

procedure Print_Hex 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 := 1;
    Count_IO.Default_Base := 16;

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

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

Result

-16#F4240#
-16#7A120#
16#0#
16#7A120#


Got any ada Question?