Member Avatar for bhaltulpule

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

> 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.