6 Replies Latest reply on Mar 22, 2013 8:47 AM by userc_39236

# Hex number to base 10

How do I convert the hex to a decimal base 0 to 9.

void Display_Result(void)
{

LCD_Char_Position(0,6);
LCD_Char_PrintString("      ");
LCD_Char_Position(1,6);
LCD_Char_PrintString("      ");
}

• ###### 1. Re: Hex number to base 10

My original email was wrong. below is the corrected version

void Display_Result(void)
{

LCD_Char_Position(0,6);
LCD_Char_PrintString("      ");
LCD_Char_Position(1,6);
LCD_Char_PrintString("      ");
}

• ###### 3. Re: Hex number to base 10

I believe I tried it. I received an email that I needed to use UNIT16. THere is the long and hard way. But I was hoping Kiel software had a function to convert the the number. I have a hex value ex: 3fad. This needs to be converted to a decimal value.

Philip

• ###### 4. Re: Hex number to base 10

when you #include <stdio.h> you may use sprintf() to convert any number to a string which you may print on LCD.

Parameters for sprintf() are here http://publications.gbdirect.co.uk/c_book/chapter9/formatted_io.html

Bob

• ###### 5. Re: Hex number to base 10

Thanks for the feedback,

My code Is as follows. I get the the hex vale in 4 digits. With the sprintf(0 can I get the complete decimal value?

void Display_Result(void)
{

LCD_Char_Position(0,6);
LCD_Char_PrintString("      ");

///////////////////////////////////////////////////////////
// sprintf()  insert conversion here ?
/////////////////////////////////////////////////////////
LCD_Char_Position(1,6);

LCD_Char_PrintString("      ");
}

• ###### 6. Re: Hex number to base 10

Bob,

Thanks for the help. My Cypress compiler at work will compile my software fine. But the same software on my home PC will not compile. I am uninstall Creator 2.1 and 2.2 CP5 from my work PC now. Then I will do a clean install? That did not occur to me to check the copilers.

Thanks Bob,

Phi