Topic : Organization of float format in RIDE when using C

Forum : Ride IDE

Original Post
Post Information Post
November 10, 2009 - 9:18am
Guest

I am using RIDE & C and I found the format of float is not startdand IEEE 754.

Do you know how it formed?

Thanks!!

Replies
Post Information Post
+1
0
-1
November 10, 2009 - 10:11am
Raisonance Support Team

Hi Kevin,

Can you tell us the Compiler you are using and its version? Our Compilers use standard IEEE-754 floating-point, but you may need to configure it, as some compilers support various float formats (BCD, little/big endian,...)

Regards,
Bruno

+1
0
-1
November 11, 2009 - 10:35am
Guest

Hi Bruno, Thank you very much!!!

I am using Raisonance Kit 6.1, Version 06.10.15, Build number : BN732-XE8000.

Thanks again!!!

+1
0
-1
November 12, 2009 - 6:13pm
Guest

Hi

In this case the compiler you use is the GNU GCC for Coolrisc.
I have checked in the actual version of our software and we do not force
any special option for floating handling.
We just pass to the compiler the define of teh target and so the default value
for this target will be apply.

To have more information about flaot representation you will need to refer to the GCC documentation.
The fastest way to find the representation used is to check in \GNU\c816-gcc\c816\include\float.h
You should find there a description of the different paramater.

Regards,
Matloub

+1
0
-1
November 13, 2009 - 3:00am
Guest

Hi Matloub,

Thanks a lot!

I will check these files as you mentioned above, pls. tell if you have any other suggestion or example!

Best Regards!

+1
0
-1
November 13, 2009 - 7:39am
Guest

Dears,

I found an example in other place, I tried but it does not work good.

Could you give me some suggestions?

Thanks!!!

//convert IEEE-Xemics to IEEE_PC
float convertToIEEEPC(unsigned char *data) {
float res;
unsigned char *pK;

pK=(unsigned char*)&res;

*pK=*(data+3);
*(pK+1)=*(data+2);
*(pK+2)=*(data+1) & 0x7f;
*(pK+3)=((*data) >> 1 )- 1;
if(*data & 0x01) *(pK+2) |=0x80;
if(*(data+1) & 0x80) *(pK+3) |=0x80;
return res;
}

//convert IEEE-PC to IEEE_Xemics

convertToIEEEDev(unsigned char *dest,float ff) {
unsigned char *f;
f=(unsigned char*)&ff;

*dest=((*(f+3))<<1)+2;
*(dest+1)=(*(f+2)) & 0x7f;
*(dest+2)=*(f+1);
*(dest+3)=*f;

if(*(f+3) & 0x80)
*(dest+1) |= 0x80;

if(*(f+2) & 0x80)
*dest |=1;
}

// :-))))

+1
0
-1
November 13, 2009 - 8:19am
Guest

I am so sorry!

The abouve example is right, I made some mistakes.

Thanks for the author of example!

Thanks for others!!!

+1
0
-1
November 13, 2009 - 10:21am
Raisonance Support Team

Hi Kevin,

Alternatively you could use the ldexp() and frexp() functions from math.h, which are standard C. They are intended for float conversion (separating the mantissa from the exponent).

Regards,
Bruno

+1
0
-1
November 14, 2009 - 4:19am
Guest

Hi Bruno,

I will test the two functions later.

Thanks!