F2Bin

Have some feedback and input to share?
Don't be shy and drop us a note. We want to hear from you and strive to make our site better and more user friendly for our guests and members a like.
Post Reply
Serggio
Posts: 46
Joined: Sun May 14, 2017 5:03 pm
Location: Ukraine

F2Bin

Post by Serggio »

F2Bin function in VO saves float in a somehow wierd format. It is mentioned that value part of the float is saved as REAL8, that should be IEEE754, but it is not. The order of bytes differs. In X# F2Bin complies with IEEE754, but not in VO. So there is a problem if you want to unpack binary value, saved in VO app, using XSharp's Bin2F, because of differences in their format.
I've made quite a research of the problem and found a way to get values of sign, exponent and mantissa from VO's F2Bin, so I can write a VO-style Bin2F in X# - a so to say VOBin2F() function.
But inspite of that I'm not very sure that I can write a proper VO-style "VOF2Bin" in X#, that will be adequately understood in VO app, because for now I need such an interoperability - both VO and X# must understand each other's binary float representation.
Robert, you've been a developer in VO team for years, maybe you have that algorythm of VO's F2Bin. It would help a lot. Thank you for any help.
User avatar
robert
Posts: 4478
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

F2Bin

Post by robert »

Serggio,
It will be VERY difficult to emulate F2Bin in X#.
VO uses Real8 (64 bit) ieee floating point numbers, F2Bin is based on the 80bit floating point numbers that the Intel Numeric coprocessor works with.
VO copies the Real8 to the numeric coprocessor and writes the bits from that coprocessor to the string.
And Bin2F does the opposite: it constructs the 80bit number from the string and then converts it to 64 bits.

I have looked everywhere but have not found a .Net library that supports the 80 bit floating point numbers that the coprocessor works with.

And to add to this: the fact that VO uses the numeric coprocessor which has 80 bits for calculations is also the reason why some (edge case) numeric calculations return slightly different results in VO than in X#. For example a Modulus operation on 2 floating point numbers may produce slightly different results.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Serggio
Posts: 46
Joined: Sun May 14, 2017 5:03 pm
Location: Ukraine

F2Bin

Post by Serggio »

Robert, thank you!
Now I see why there is a 15-bit exponent and not a 11-bit one. I'll try to think something out :)
There are algorythms to convert 80-bit float to 64-bit one. Will try to emulate something like 64 -> 80 also.
I still would like to try.
User avatar
robert
Posts: 4478
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

F2Bin

Post by robert »

Serrgio,

Maybe the intel docs about the numeric coprocessor can explain how things are stored ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Serggio
Posts: 46
Joined: Sun May 14, 2017 5:03 pm
Location: Ukraine

F2Bin

Post by Serggio »

I've made an X# function VOBin2F which converts VO's F2Bin() result to a float (see the attachment). As for now I'll try to avoid making a reverse function. Let it be as it is.
Attachments
VOFloat.zip
(1.25 KiB) Downloaded 148 times
Post Reply