BUG DESCRIPTION:
----------------
bitget() has several pitfalls and limitations:
a) The bug 2694 is not fully fixed: Positive signed encoded integers are still not supported
b) new uint64 and int64 integers are still not supported
c) decimal numbers: bits indices pos are limited to 52 instead of log2(number_properties("huge")) == 1024
d) For decimal numbers x > 2^52 with pos < log2(x)-52, 0 is returned instead of %nan
e) It is not possible to query the value of more than 1 bit from each component of an array.
These issues are illustrated herebelow.
They should be tackled and fixed.
---- Scilab 6.0 ----
a) Positive signed encoded integers are still not supported:
--------------------------------------------------------
--> bitget(int8(123), 5)
at line 53 of function bitget ( SCI\modules\elementary_functions\macros\bitget.sci line 66 )
bitget: Wrong input argument #1: Scalar/matrix of unsigned integers expected.
EXPECTED:
--> bitget(int8(123), 5)
ans =
1
b) new uint64 and int64 integers are still not supported:
-----------------------------------------------------
--> bitget(uint64(2^60), 61)
at line 72 of function bitget ( SCI\modules\elementary_functions\macros\bitget.sci line 85 )
Undefined variable: posmax
EXPECTED:
--> bitget(uint64(2^60), 61)
ans =
1
c) decimal numbers: bits indices pos are limited to 52 instead of log2(number_properties("huge")) == 1024
------------------------------------------------------------------------------------------------------
--> bitget(2^100, 101)
at line 73 of function bitget ( SCI\modules\elementary_functions\macros\bitget.sci line 86 )
bitget: Wrong value for input argument #2: Must be between 1 and 52.
EXPECTED:
--> bitget(2^100, 101)
ans =
1.
d) For decimal numbers x > 2^52 with pos < log2(x)-52, 0 is returned instead of %nan
---------------------------------------------------------------------------------
--> bitget(2^3+2^60, 4)
ans =
0.
EXPECTED:
--> bitget(2^3+2^60, 4)
ans =
Nan
Actually, we can't know the value. So => %nan
e) It is not possible to query the value of more than 1 bit from each component of an array.
----------------------------------------------------------------------------------------
--> x = cumsum(2.^([1 2 ; 3 4]-1))
x =
1. 7.
5. 15.
--> bitget(x, [1 3 4])
at line 44 of function bitget ( SCI\modules\elementary_functions\macros\bitget.sci line 57 )
bitget: Wrong size for input arguments: Same size expected.
EXPECTED:
--> bitget(x, [1 3 4])
ans =
1. 0. 0. // x(1)
1. 1. 0. // x(2)
1. 1. 0. // x(3)
1. 1. 1. // x(4)
ERROR LOG:
----------
HOW TO REPRODUCE THE BUG:
-------------------------
r = 0;
execstr("r = bitget(int8(123), 5)", "errcatch")==0, r==1
execstr("r = bitget(int16(123), 5)", "errcatch")==0, r==1
execstr("r = bitget(int32(123), 5)", "errcatch")==0, r==1
execstr("r = bitget(int64(2^60), 61)", "errcatch")==0
r==1
execstr("r = bitget(uint64(2^60), 61)", "errcatch")==0
r==1
execstr("r = bitget(2^100, 101)", "errcatch")==0
r==1
isnan(bitget(2^3+2^60, 4))
OTHER INFORMATION:
------------------
Fix needed to fix bitset() (bug 12013 and bug 14655)