error on decode-int32 #20
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I met this error
get error below
It seems wrong covert on
osc::decode-int32
.(osc::decode-int32 (osc::encode-int32 2147483647)) ;; result is -2147483649
I think correct value of
(osc::decode-int32 #(127 255 255 255))
is2147483647
I test it other language and I got
2147483647
.Thanks for the report. there may be some issues with signed/unsigned ints...
(osc::decode-int32 #(127 255 255 255))
=>-2147483649
(osc::decode-uint32 #(127 255 255 255))
=>2147483647
I'll have a closer look at how this works with the recent changes to floats.
The tests in other languages (htonl) convert the array to unsigned int. If you use decode-uint32 you'll get the result you are expecting. However even if we use uint32
We get
By bits does the ieee-float API means it expects an unsigned-integer?
The vector in question basically is every bit but the sign bit set to 1. Using sbcl's API I get
so it does look the array does not encode a valid float
@byulparan What number are you expecting 2147483647 (
#x7FFF
) to represent?I think
(osc::decode-float32 #(127 255 255 255))
should be returnNaN
.I've updated the code to use ieee-floats and floats should work more reliably since
f9625946fd
. If you can checkout the recent changes on thecore
branch let me know if it works for you...so,
(osc::decode-float32 #(127 255 255 255))
should now return:NOT-A-NUMBER
(ieee-floats returns :keywords since there isn't a standard representation of NaN) it also means that -0e0, -0d0,:positive-infinity
and:negative-infinity
should be decoded correctly.There are some more extensive tests for float32 and float64 in osc-tests.lisp
I checkout recent version and
(osc::decode-float32 #(127 255 255 255))
is return:NOT-A-NUMBER
now😄I'll wait resolve issues with signed/unsigned ints.
(osc::decode-int32 #(127 255 255 255))
!=(osc::decode-uint32 #(127 255 255 255))
iiuc the issue is that 127 255 255 255 has the sign bit set to 0 so it should not be a negative number. If that is so the issue is an off by 1 error.
yes @PuercoPop is correct, changes added at
f647738ccc
, both the following should now be true...Thank you! I will close this issue 😃