From: John Speth on
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: news(a)netfront.net ---
From: Spehro Pefhany on
On Fri, 28 May 2010 12:06:13 -0700, "John Speth" <johnspeth(a)yahoo.com>
wrote:

>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.
>
log10(x) ?


From: D Yuniskis on
Hi John,

John Speth wrote:
> 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?

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)
From: Tim Wescott on
On 05/28/2010 12:29 PM, Spehro Pefhany wrote:
> On Fri, 28 May 2010 12:06:13 -0700, "John Speth"<johnspeth(a)yahoo.com>
> wrote:
>
>> 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.
>>
> log10(x) ?
>
>
floor(log10(x))

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
From: John Speth on
>>> Does anyone know of a way in C code to get the base 10 integer exponent
>>> of a
>>> single precision float?

>> log10(x) ?
>>
>>

> floor(log10(x))

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

JJS



--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---