Base 10 exponent of a float

Hi folks-

I think my brain is blocked and google isn't showing any solutions:

Does anyone know of a way in C code to get the base 10 integer exponent of a single precision float?

Thanks, John.

--- news://freenews.netfront.net/ - complaints: snipped-for-privacy@netfront.net ---

Reply to
John Speth
Loading thread data ...

log10(x) ?

Reply to
Spehro Pefhany

I'm not sure what you are getting at :< (perhaps parentheses in your question would make it clearer :> )

I.e., do you want the exponent field of the float expressed as a decimal integer? For example:

int exponent; double fraction = frexp((double) x, int &exponent); print("The exponent is %d.\n", exponent);

Could you represent your float algebraically in terms of the quantity you are after to be more clear? I.e., for the above:

x = fraction * (2 ** exponent)

(more or less)

Reply to
D Yuniskis

floor(log10(x))

--
Tim Wescott
Control system and signal processing consulting
 Click to see the full signature
Reply to
Tim Wescott

Thanks, Tim. That worked! I knew it was something simple.

JJS

--- news://freenews.netfront.net/ - complaints: snipped-for-privacy@netfront.net ---

Reply to
John Speth

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.