converting between Little Endian and Big Endian for signed int, float values ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

converting between Little Endian and Big Endian for signed int, float values ?

1,300 Views
Amit_Kumar1
Senior Contributor II

Hi

I am using K60 uc with CW 10.6. Using structure I am storing some values and printing it. The datatypes present in the structure has signed int, unsigned int 32, float.... When I am printing it , the values are appearing to be flipped(as uc is little endian). I tried converting it so that It appears in Big Endian form  but it didn't worked well.

 

Firstly I tried using    __builtin_bswap32();           // Present in GCC compiler

It works fine for uint32_t .but It didn't worked for float values.

 

then I tried using  


ntohl();           //Network to Host byte order (Long)
htonl
();          //Host to Network byte order (Long)

 

for this I didn't new what header files to include, and so it didn't worked.

 

 

then I searched ARM's website and got a document  http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491i/BABBHFJF.html but again this was not for single value. and didn't worked. 

 

Is there any command which does this ??

Kind Regards

Amit Kumar

Labels (1)
0 Kudos
1 Reply

748 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello Amit Kumar,

please check if you can find something useful in professor Erich Blog:

A little or big Indian? A Plea for Peace… | MCU on Eclipse

==========================================

this answer is for you, if it helps, please click on "correct answer" button. thanks!

Best Regards,

Zhang Jun

0 Kudos