summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg/slice1.adb
blob: 4c24975f7a2816f9c0712f75305ee21448afc602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- { dg-do compile }
-- { dg-options "-O2" }

function slice1 (Offset : Integer) return String is
   
   Convert : constant String := "0123456789abcdef";
   Buffer  : String (1 .. 32);
   Pos     : Natural := Buffer'Last;
   Value   : Long_Long_Integer := Long_Long_Integer (Offset);

begin
   while Value > 0 loop
      Buffer (Pos) := Convert (Integer (Value mod 16));
      Pos := Pos - 1;
      Value := Value / 16;
   end loop;
   
   return Buffer (Pos + 1 .. Buffer'Last);
end;