This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

changing hex value to decimal

hi,

how to change the value of hex to decimal

For example from hex "0x15" to decimal 15 or in hex like 0x0f.

do we have any option in keil or any other way.

Thankyou

arun.

Parents
  • "do we have any option in keil or any other way."

    Option for what?

    1) 0x15 is not decimal 15 but decimal 21.

    2) Hexadecimal or decimal - it's still the same number. So for your questions to be meaningful, you have to specify how, when, where.

    Do you have numbers you need to read in? A function like strtol() can handle decimal, octal or hexadecimal automatically if the hexadecimal numbers always starts with 0x or 0X and the octal numbers always starts with 0 and decimal numbers do not start with 0 (note decimal 0 and octal 0 is the same number so no ambiguity).

    DO you need to print numbers? printf() can print the number in hex or decimal.

    For source code constants, you don't need any conversions, since the compiler will treat the constants as numbers and don't care about if the constant was represented as decimal or hexadecimal in the source code.

    Or you want to write a pocket calculator, where you yourself convert between numeric bases digit-by-digit? That is easy too, and can be done in more than one way.

Reply
  • "do we have any option in keil or any other way."

    Option for what?

    1) 0x15 is not decimal 15 but decimal 21.

    2) Hexadecimal or decimal - it's still the same number. So for your questions to be meaningful, you have to specify how, when, where.

    Do you have numbers you need to read in? A function like strtol() can handle decimal, octal or hexadecimal automatically if the hexadecimal numbers always starts with 0x or 0X and the octal numbers always starts with 0 and decimal numbers do not start with 0 (note decimal 0 and octal 0 is the same number so no ambiguity).

    DO you need to print numbers? printf() can print the number in hex or decimal.

    For source code constants, you don't need any conversions, since the compiler will treat the constants as numbers and don't care about if the constant was represented as decimal or hexadecimal in the source code.

    Or you want to write a pocket calculator, where you yourself convert between numeric bases digit-by-digit? That is easy too, and can be done in more than one way.

Children
No data