OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [compile/] [950729-1.c] - Blame information for rev 868

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
static const char * const lcset = "0123456789abcdef";
2
static const char * const ucset = "0123456789ABCDEF";
3
 
4
char *
5
f (char *buffer, long long value, char type)
6
{
7
  int base, i;
8
 
9
  i = 128  - 1;
10
  buffer[i--] = '\0';
11
 
12
  switch (type)
13
    {
14
    case 'u':
15
    case 'o':
16
    case 'x':
17
    case 'X':
18
      if (type == 'u')
19
        base = 10;
20
      else if (type == 'o')
21
        base = 8;
22
      else
23
        base = 16;
24
 
25
      while (i >= 0)
26
        {
27
          if (type == 'X')
28
            buffer[i--] = ucset[((unsigned long long) value) % base];
29
          else
30
            buffer[i--] = lcset[((unsigned long long) value) % base];
31
 
32
          if ((value = ((unsigned long long) value) / base) == 0)
33
            break;
34
        }
35
      break;
36
    }
37
 
38
  return &buffer[++i];
39
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.