[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Brain cramp converting a hex value to decimal



> I'm getting an integer value from a function that's in hex (0x004F).  I want
> to convert it to decimal (79), actually to each character of the decimal
> value or 7 and 9, so I can then look up on an lcd table to see what values
> correspond to each character.

If your "hex" value is a string, use strtol(value,0,16) to parse
it as a hex value and return a numeric value.

Then, or if you already have a numeric ("int foo;") value, use
sprintf(buf,"%d",value) to format it as a decimal string.  Then you
can pull the individual characters out of the buffer.


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user