Beispiel #1
0
char			*ft_htoa_min(unsigned long long n)
{
    char			*p;
    int				size;
    unsigned long long	x;

    x = n;
    size = 0;
    while (x > 15)
    {
        x = x / 16;
        size++;
    }
    p = (char *)malloc(sizeof(p) * (size + 1));
    if (p)
    {
        p[size + 1] = '\0';
        while (size >= 0)
        {
            x = n % 16;
            p[size] = hexavalue(x);
            n = n / 16;
            size--;
        }
    }
    return (p);
}
Beispiel #2
0
char			*ft_mhtoa(uintmax_t n)
{
	char			*p;
	int				size;
	uintmax_t		x;

	x = n;
	size = 0;
	while (x > 16)
	{
		x = x / 16;
		size++;
	}
	p = (char *)malloc(sizeof(p) * (size + 1));
	if (p)
	{
		p[size + 1] = '\0';
		while (size >= 0)
		{
			x = n % 16;
			p[size] = hexavalue(x);
			n = n / 16;
			size--;
		}
	}
	return (p);
}
Beispiel #3
0
static int readhexaesc (tt_Lexer *L) {
  int c[3], i;  /* keep input for error message */
  int r = 0;  /* result accumulator */
  c[0] = 'x';  /* for error message */
  for (i = 1; i < 3; i++) {  /* read two hexa digits */
    c[i] = ttL_next(L);
    if (!isxdigit(c[i]))
      escerror(L, c, i + 1, "hexadecimal digit expected");
    r = (r << 4) + hexavalue(c[i]);
  }
  return r;
}