Binary Encode/Decode bug?
Mark Smith
mark at maseurope.net
Mon Aug 20 09:29:08 EDT 2007
Is this a bug ?- it seems like one.
put binaryEncode("n", someNumber) into tBinNum
put empty into bdOutput
get binaryDecode("n", tBinNum, bdOutput)
"n" is the parameter for 2-byte signed integers in network byte
order (bigEndian).
"s" is the parameter for 2-byte signed integers in host byte order
(littleEndian in my macIntel case).
If "someNumber" (the input) >= 0 then the output ("bdOutput") = the
input as you'd expect, but if the input < 0, then I'm getting input
<> output.
I'm on an intel Mac.
On the other hand, if I swap the two bytes of "tBinNum" and use "s"
in the decode, then I get the right result ie.
put binaryEncode("n", someNumber) into tBinNum
put char 2 of tBinNum & char 1 of tBinNum into tBinNum -- swap
put empty into bdOutput
get binaryDecode("s", tBinNum, bdOutput)
input = output for any input.
Should I bugzilla this?
Best,
Mark
More information about the use-livecode
mailing list