EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

hex to decimal conversion in c

Started by Madhav J Joshi May 6, 2005
I am learning to use embedded c for msp430. I am using IAR c compiler 
which comes with the kick start.
I will appreciate some help on the following : 

Please let me know whether there is any standard c function which 
converts hex value into decimal value ,say by simply writing following  
type of code : 
DecimalValueVariable= C_ConversionFunction(HexValueVariable);

If such standard function is not avaialable then how to do this?

Thanks for your time and help in advance.
Madhav Joshi
www.msp430total.com



Beginning Microcontrollers with the MSP430

variables always store the number in binary, how you deal with it from there 
is up to you, so this question doesn't make sense to me. 

Are you storing a hex value as characters, and which to convert it back to a 
number?

-Micah


On Friday 06 May 2005 04:10 pm, Madhav J Joshi wrote:
> I am learning to use embedded c for msp430. I am using IAR c compiler
>  which comes with the kick start.
>  I will appreciate some help on the following :
>
>  Please let me know whether there is any standard c function which
>  converts hex value into decimal value ,say by simply writing following
>  type of code :
>  DecimalValueVariable= C_ConversionFunction(HexValueVariable);
>
>  If such standard function is not avaialable then how to do this?
>
>  Thanks for your time and help in advance.
>  Madhav Joshi
>  www.msp430total.com
>
>
>
>
>  .
>
>
>
>
>
> .

In addition, if you are using the "watch" functionality in IAR
Embedded Workbench C-Spy, you can inidividually change the way variables appear
by just clicking on the interested variable, and then changing the view type
from the current to hex, decimal, etc etc.

However, if the end result should be ASCII characters, and you want to convert,
say, binary 1111000011110000 (read Micah below) to hex ASCII (meaning
"0xF0F0", and NOT 0xF0F0), you can easily write a function for that. 

IL

----- Original Message ----- 
  From: Micah Stevens 
  To: msp430@msp4... 
  Sent: Friday, May 06, 2005 5:23 PM
  Subject: Re: [msp430] hex to decimal conversion in c



  variables always store the number in binary, how you deal with it from there 
  is up to you, so this question doesn't make sense to me. 

  Are you storing a hex value as characters, and which to convert it back to a 
  number?

  -Micah


  On Friday 06 May 2005 04:10 pm, Madhav J Joshi wrote:
  > I am learning to use embedded c for msp430. I am using IAR c compiler
  >  which comes with the kick start.
  >  I will appreciate some help on the following :
  >
  >  Please let me know whether there is any standard c function which
  >  converts hex value into decimal value ,say by simply writing following 
  >  type of code :
  >  DecimalValueVariable= C_ConversionFunction(HexValueVariable);
  >
  >  If such standard function is not avaialable then how to do this?
  >
  >  Thanks for your time and help in advance.
  >  Madhav Joshi
  >  www.msp430total.com
  >
  >
  >
  >
  >  .
  >
  >
  >
  >
  >
  > .


  .





------
  . 






About 45y ago I had a similar question :) My old instructor said the
following :

Alex, sit down with paper and pencil. write the first 16 hexadecimal values
in
a vertical column. After every value write an equal sign in the third column
write the
number in the base you want to convert.
When you have finished lock at it for 10 minutes. If you have not found the
answer
in that period of time you are in the wrong class :)

I can remember it like it happened yesterday :)


Alex




----- Original Message ----- 
From: "Madhav J Joshi" <madhavjj@madh...>
To: <msp430@msp4...>
Sent: Friday, May 06, 2005 7:10 PM
Subject: [msp430] hex to decimal conversion in c


> I am learning to use embedded c for msp430. I am
using IAR c compiler
> which comes with the kick start.
> I will appreciate some help on the following :
>
> Please let me know whether there is any standard c function which
> converts hex value into decimal value ,say by simply writing following
> type of code :
> DecimalValueVariable= C_ConversionFunction(HexValueVariable);
>
> If such standard function is not avaialable then how to do this?
>
> Thanks for your time and help in advance.
> Madhav Joshi
> www.msp430total.com
>
>
>
>
> .
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>


Back in the early '80s there was a spare place on a training course
for system managing Prime computers, so as the recent graduate I was
sent.  I had the misfortune to sit next to someone who continually
failed to get the answer to just the same question.  For every system
call that we looked at he had to enter the data in binary, hexadecimal
and decimal just to check that the computer understood the different
data formats.  How the instructor kept any sense of humour after being
asked for the hundredth time " What happens if I enter this in hex?" 
I will never know.

Ian

On 5/7/05, alex@alex... <alex@alex...> wrote:
> About 45y ago I had a similar question :) My old instructor said the
> following :
> 
> Alex, sit down with paper and pencil. write the first 16 hexadecimal values
> in
> a vertical column. After every value write an equal sign in the third
column
> write the
> number in the base you want to convert.
> When you have finished lock at it for 10 minutes. If you have not found the
> answer
> in that period of time you are in the wrong class :)
> 
> I can remember it like it happened yesterday :)
> 
> Alex
> 
> ----- Original Message -----
> From: "Madhav J Joshi" <madhavjj@madh...>
> To: <msp430@msp4...>
> Sent: Friday, May 06, 2005 7:10 PM
> Subject: [msp430] hex to decimal conversion in c
> 
> > I am learning to use embedded c for msp430. I am using IAR c compiler
> > which comes with the kick start.
> > I will appreciate some help on the following :
> >
> > Please let me know whether there is any standard c function which
> > converts hex value into decimal value ,say by simply writing following
> > type of code :
> > DecimalValueVariable= C_ConversionFunction(HexValueVariable);
> >
> > If such standard function is not avaialable then how to do this?
> >
> > Thanks for your time and help in advance.
> > Madhav Joshi
> > www.msp430total.com
> >
> >
> >
> >
> > .
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> 
> .
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
>


The 2024 Embedded Online Conference