System.BitConverter

I have been writing a layer around our DCOM interface of the last few days, and today I needed to convert a double to 8 byte stream.

Low and behold a new .Net 2.0 helper class System.BitConverter, very useful. I chose to use the DoubleToInt64Bits method so I could control the order the bytes are written, but if I had found this class earlier I might have used for all conversions. There is still time to refactor…

This class would have also been helpful when converting Pascal 6 byte real’s to IEEE 8 byte double’s for my Curse of the Azure Bonds port. My previous code used unsafe code to write into the double directly… Hmm can’t find the old code…. will have to dig it up and rewrite it.