Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert decimal to binary or hex

Status
Not open for further replies.

kshea

Technical User
May 31, 2002
60
CA
Hi All,

How do I convert a decimal value to Hexa value and binary value ?

Thanks
 
[tt]_ttoi[/tt] for converting a string (_T("26")) to an int (26)
[tt]_tcsprintf[/tt] for converting an int (26) to a hex string (_T("1A"))
 
kshea,

A decimal value is already a hex and binary value

int a = 10;

now a is all the above (decimal,hex,binary)

Ask your question more specifically.

-pete
 
Is this for display purposes ?

int n = 10;

printf("%d %X\n", n, n);

This will display dec and hex for example
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top