[En-Nut-Discussion] Floating Point support for ARM7 + Ethernut
ml
mludwig at adc-elektronik.de
Tue Oct 2 18:01:32 CEST 2007
only with cast´s it will not work. float structure in memory is completly
different form integers
use trunc or round function to get an int
and simply assign an int to a float in the other way round
martin
Lidya wrote:
>
> I need to convert: floating point value <----> unsigned int
> based on the IEEE 754 standard.
>
> I have these functions that will do the convertion:
>
> unsigned int ToInt(float floatValue)
> {
> float* pf = &floatValue;
> void* pv = (void*) pf;
> return (*((unsigned int*)pv));
> }
>
> float ToFloat(unsigned int u)
> {
> unsigned int* pu = &u;
> return (*((float*)pu));
> }
>
> However invalid value are resulted.
> Do I need the Floating Point support for NutOS or some more libraries to
> be included??
> If anyone knows how to do it, please inform me.
>
> Thanks :)
>
--
View this message in context: http://www.nabble.com/Floating-Point-support-for-ARM7-%2B-Ethernut-tf4554262.html#a13001635
Sent from the MicroControllers - Ethernut mailing list archive at Nabble.com.
More information about the En-Nut-Discussion
mailing list