-3

I want to convert decimal number to hexadecimal in Embedded C.

Actually in my project input to controller is decimal which will be subtracted from hexadecimal value, so I need a conversion.

I tried to write it but after converting a number (75 for example) to its hexadecimal equivalent it will be (411). The trouble is that I did not know how to convert a number like 11 to b in hexadecimal as you know that there is no 11 in hexadecimal, it is b; so please help.

I want to save the converted value in a flag (for subtracting), not for printing. I can print a hex value by simple put a condition like:

(if (a > 10) printf("b"))

but this is not a solution for Embedded.

So please give me a complete solution.

4

1 回答 1

0

我不确定你的意思,但你的整数只是“解释类型”。在你的记忆中,它只是一堆 0 和 1,因此你也可以用十进制、十六进制的方式表示“数据”。

如果您需要它作为寄存器的输入,您可以将其传递给它。还是我误解了你的问题?

于 2012-08-16T10:35:27.177 回答