How can I convert four bytes of binary data (big endian) to an IEEE floating point value using C#?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A simple solution would be to reverse the incoming array and give that to the .Net Framework’s
BitConverter:For a full-fledged bit-converter that works with big-endian values, take a look at
MiscUtil.Conversion.BigEndianBitConverterin the MiscUtil library by Jon Skeet and Marc Gravell, and then useToSingle(byte[] value, int startIndex):The methods it supports are the same as those of the
BitConverterclass in the .Net framework. The source can be found on the MiscUtil website.