Fixed to Floating point conversions

Reply

Join Date: Apr 2008
Posts: 3
Reputation: bhaltulpule is an unknown quantity at this point 
Solved Threads: 0
bhaltulpule bhaltulpule is offline Offline
Newbie Poster

Fixed to Floating point conversions

 
0
  #1
Apr 8th, 2008
I am relatively new to C. I need to use to convert values generated by an A to D converter (000h to FFFh) into floating point numbers. One way that this can be done is using the Float command as in x = (float) y. Is there a better way ? More important, is the result in IEEE Floating binary point format (standard 754) or some other format. I am using a 8051 micro and Keil toolset for the C compiler.
If the result is in IEEE format I want to convert it into decimal format format and send it a PC or Hyperterminal so I can see it. Seems like a lot of character manipulation is required for this. Is there some standard math routine that already does this ?

THanks.

Bhal Tulpule
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Fixed to Floating point conversions

 
0
  #2
Apr 8th, 2008
> More important, is the result in IEEE Floating binary point format (standard 754) or some other format.
No idea - read your compiler documentation to find out how it represent floats.

If you're mapping 000h to 0 and FFFh to 4095, then just leave it as an integer.
Or are you scaling it to a float between 0.0 and 1.0 (or some other range).

> Is there some standard math routine that already does this ?
Like sprintf()

> Is there a better way ?
Depends on what you mean by "better". Is the simple thing taking up way too much space by pulling in a large library, or is it too slow?
If it is IEEE, you could carefully store the A/D value in the mantissa, and adjust the exponent accordingly.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC