AnsweredAssumed Answered

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

Question asked by Amit Kumar on Sep 17, 2014
Latest reply on Sep 18, 2014 by ZhangJennie

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

Outcomes