In this question, Bill The Lizard asks how to display the binary representation of a float or double.
What I’d like to know is, given a binary string of the appropriate length, how could I perform the reverse operation (in C#)? In other words, how do I turn a binary string into a float or double?
As a side note, are there any bit strings which would not result in a valid float or double?
EDIT: By binary string I mean a string of 0s and 1s.
So, my input will be a string like this:
01010101010101010101010101010101
and my output should be a floating point number. (Or, if there were 64 bits in the string, a double.)
1 Answer