Social Nerwork

Telephone us on: +353 87 223 6429 or email us using: info@ridgesolutions.ie
Telephone us on: +353 87 223 6429 or email us using: info@ridgesolutions.ie

An implementation of ntohf() with code

I am working on extracting data from some binary navigation messages today. Working with binary data can be difficult and quite confusing – especially when converting byte order from network (big endian) to host byte order (possibly little endian). The integer types are well covered by ntohs() and ntohl() et al. but when dealing with floats things can get a bit harder as ntohf() isn’t always available to the hard pressed programmer!

So I have included a simple implementation below, I have tested it during my own use, but it use at your own risk as this code may well be an example of a rather dubious use of unions!

This version is slightly adapted from an original implementation by Kevin Bowling (pls. see copyright notice).

LEAVE A REPLY

 

Google+