I've found the following question Convert Delphi Real48 to C# double but I want to go the other way, C# to Delphi.
Does anyone know how this can be done? I've tried reverse engineering the code but without much luck.
Update:
I'm after C# code that will take a double and convert it into a Real48 (byte[] of size 6).
Thanks
In C/C++
I came across this thread looking for the same code. Here is what I ended up writing:
Real48 is similar to IEEE 754 in that the Mantissa will be the same. The bit shift are necessary to get the Mantissa in the right location.
Real48 exponent has a bias of 129 and the double has a bias of 1023.
The negative flag is stored in the first bit of the last byte.
Notes: I don't think this code will work on a big endian machine. It does not check for NAN or INF.
Here is the code that converts a real48 to a double. It was ported from the Free Pascal compiler:
If you're familiar with C (as you're writing in C# you should be fine), check out this function. Moving it across into C# should not be too difficult.
It's rather ugly, but neccesary I'm thinking.
Reference: http://forums.ni.com/ni/board/message?board.id=60&message.id=3553
The simplest way, if possible, would be to convert it to a string, pass, then convert it back to a Real48