Right, so i have a piece of code which converts an IEEE float (Number) in vb to a different representation of exponent and mantissa.
Im having great difficulty converting this to C# due to the way the code deals with bit masking of whole byte arrays. Anyone able to help?
Im having great difficulty converting this to C# due to the way the code deals with bit masking of whole byte arrays. Anyone able to help?
Code:
If (Number And &H80000000) = &H80000000 Then
'negative
'mask off the sign bit
Number = (Number And &H7FFFFFFF)
Mantissa = &HC000& - ((Number And &H7FFFFF) \ (2 ^ 9))
Else
Mantissa = &H4000& + ((Number And &H7FFFFF) \ (2 ^ 9))
End If
'positive
If Number = 0 Then
' zero is represented as Mantissa 0 and Exponent 128
Mantissa = 0: Exponent = &H80&
Else
Exponent = (((Number \ (2 ^ 23)) - 126&) And &HFF&)
End If