Stephen.Leake@gsfc.nasa.gov Stephen Leake at NASA Goddard Space Flight Center Markus Kuhn wrote: > > Did I missunderstand something or is there really no support in the > standard Ada packages to output a hexadecimal number without > 16#...# and with leading zeros? Do I have to implement the > equivalent of printf("%04x", v); myself in Ada95? Yes, but it's actually quite easy. Here's one I wrote: procedure Put_Hex (To : out String; Last : in out Natural; Width : in Natural; Item : in Interfaces.C.Unsigned_Long) -- put hex image of Item, with leading zeros to Width, in String -- (Last + 1 .. ). Update Last to last character written. is use type Interfaces.C.Unsigned_Long; Temp : Interfaces.C.Unsigned_Long := Item; Nibble : Interfaces.C.Unsigned_Long range 0 .. 15; begin for I in reverse 1 .. Width loop Nibble := Temp mod 16; Temp := Temp / 16; if Nibble <= 9 then To (Last + I) := Character'Val (Character'Pos ('0') + Nibble); else To (Last + I) := Character'Val (Character'Pos ('A') + Nibble - 10); end if; end loop; Last := Last + Width; end Put_Hex; -- - Stephe