Har VB6 kode som gjør jobben, om det gjør det hele enklere.
Forklaring:
The protocol uses a floating point number witch is defined by two
bytes, not four bytes IEEE 32.
The following format (in the communication buffer will be in the
sequence from the least
significant byte to the most significant byte) the 16 bits string is
characterized by three components,
an exponent, a sign and a significant. Its numerical value is the
signed product of its significant and
two raised to the power of its exponent.
2 Bytes Floating Point Format
4 1 11 ...width
e s f
msb lsb msb lsb ...order
b0 b10 ...bit index
where:
e 4 bits exponent. Any integer between 0 and 15
s 1 bit sign (0 = positive, 1 = negative)
f 11 bits fractional significant with an implied binary point and the
format: 0.b0b1...b10
Total 16 bits.
The numerical value of a floating point string can be calculated as:
Numerical Value = (-1)s 2e (0.b0b1...b10)
The numerical value of the nth bit (bn) in the significant field (n
from 0 to 10) is:
Significant Value(bn) = 2-(n + 1)
A number is zero when all bits of the fractional significant are 0.
Må ha kode som gjør jobben begge veier..
Eksempler:
1400 = 1
B001 = 1
1C00 = -1
B801 = -1
7640 = 100
B064 = 100
41A0 = 20,0
0000 = 0
0001 = 0.1
4563 = 26.2
4582 = 72.6