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

Subversion Repositories openfire2

[/] [openfire2/] [trunk/] [sw/] [lib/] [puthexstring.c] - Rev 4

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

#include "openfire.h"
 
static char puthexchar(unsigned n)
{
  n &= 0xF;
  return n + (n < 10 ? '0' : 'A' - 10);
}
 
void puthexstring(char *string, unsigned number, unsigned size)
{
  int n = size - 1;
  while(number && n >= 0)		// hex 2 ascii right to left
  {
    string[n] = puthexchar(number & 0xf);
    number >>= 4;
    n--;
  }
  while(n >= 0) string[n--] = '0';	// left padding with 0
}
 

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

powered by: WebSVN 2.1.0

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