| | |
Fixed to Floating point conversions
![]() |
•
•
Join Date: Apr 2008
Posts: 3
Reputation:
Solved Threads: 0
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
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
> 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.
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.
![]() |
Other Threads in the C Forum
- Previous Thread: Converting a Long Long to a Char Buff
- Next Thread: Artificial Intelligence to C
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram homework i/o ide inches include infiniteloop input interest intmain() iso keyboard km license linked linkedlist linux list looping lowest matrix meter microsoft mysql number oddnumber open opendocumentformat openwebfoundation pdf pointer posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard strchr string suggestions systemcall test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






