Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Converting 32bit hex to a float for 89s52 in C/C++

Status
Not open for further replies.

m2star

Junior Member level 1
Joined
May 1, 2010
Messages
18
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
Rawalpindi, Pakistan, Pakistan
Activity points
1,390
hi all
i need to know the method for converting 32bit hex to a float for 89s52 in c/c++
can anyone help


please.........



m2star
 

Re: convert hex to float

hi all
i need to know the method for converting 32bit hex to a float for 89s52 in c/c++
can anyone help


please.........



m2star

I really don't understand the question, what is the difference of a hex with a float, the only sensible format change I could think of is if you want to show the number in an lcd which means that you want to convert the number to ascii chars in an array.
 

Re: convert hex to float

Not actually a clear question. "32bit hex" means? A hex string representing 32 bits? Or just a binary number? An converting to which float format? A decimal string? Or a binary IEEE-754 representation?
 

Re: convert hex to float

my question is how to convert hexadecimal to a float
like i have a no 4203fc36H that is equal to 32.9963 in float
how can i convert them to each other
 

Re: convert hex to float

The "hex" number is actually a 32 bit float value. Read about single precision IEEE float format.
IEEE 754-1985 - Wikipedia, the free encyclopedia

The conversion will be normally done by your computer, either the compiler, a debug tool, or the microprocessor at run time, using library functions.

You can however perform the conversion with a pocket calculator, if you want to.

0x4203fc36 splits into
sign 0 means +
exponent 0x84 = 127 + 5, means 2^5 or factor 32
mantissa 0x3fc36, means 1 + 0x3fc36/2^23 = 1.031134
+(32 * 1.031134) = 32.9963

And vice versa (left for you).
 
  • Like
Reactions: m2star

    m2star

    Points: 2
    Helpful Answer Positive Rating
Re: convert hex to float

You have to provide further info of what you are trying to do.

If I told you that I wanted to convert a hex (like 0x0F) to an integer (like decimal 15) would it make sense to you?
These two values are the same , you can either write my_var=0x0F or my_var=15 with the same result and it is the same with the values that you ask about so what exactly are you trying to do?

Are you trying to convert the float into an ASCII representation to show it in an lcd or send it with UART or something?
 

Re: convert hex to float

@ FvM
thanks for your consultation
your answer is exactly matching to the solution i got from IEEE standard 754 as in the link below

**broken link removed**
 

Re: convert hex to float

Your question was
convert 32bit hex to a float for 89s52 in c/c++
so you were asking for mcu code to make the conversion but what you actually wanted had no relevance with that at all, you just wanted to convert a number from one system to the other using some tool or calculation by hand in order to understand the value it represents.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top