[Scilab-users] Bitget for int64/uint64
Jan Åge Langeland
j-lan at online.no
Thu Feb 27 17:58:25 CET 2020
Samuel
My suggestion for a workaround (looks like my first reply disappeared):
b =uint64(2)^61+1
bb2=uint64(bin2dec(strsplit(strrev(bitstring(b))))');
bb1=bitget(b,1:64);
bb2(1)-bb1(1)
ans = 1
A bit of a waste to use uint64 to store single bits, but that is what
bitget does:
--> typeof(bb1)
ans = "uint64"
Jan
On 2020-02-27 17:51 PM, Samuel Gougeon wrote:
> As suspected, the bug originates from the * operator, that is still
> not reliable between uint64 or int64:
> --> b
> b =
> 230584300921369395*5*
>
> --> b * uint64(1)
> ans =
> 230584300921369395*2*
>
> This was reported in 2018 @ http://bugzilla.scilab.org/15836 and is
> still unfixed.
>
> For bitget, i will see how to do, if there is a workaround. If not, at
> least warn users in the help page.
>
> Samuel
>
> Le 27/02/2020 à 16:58, Samuel Gougeon a écrit :
>> Le 27/02/2020 à 16:17, JLan a écrit :
>>> I wonder if i have misunderstood the documentation for bitget, or if
>>> this is
>>> a bug? It seems to me that numbers > 2^53 are still not handled
>>> correctly.
>>> --> a=uint64(2^61)
>>> a = 2305843009213693952
>>> --> b=uint64(2^61)+1
>>> b = 2305843009213693953
>>
>> bitget(b,1)
>>
>> --> bitget(b,1)
>> ans =
>> 0
>>
>> is a bug.
>> bitget.tst tests int64 and uint64 cases with other inttypes:
>> --> edit SCI\modules\elementary_functions\tests\unit_tests\bitget.tst
>>
>> When bitget() has been extended to 64 bits integers ~3 years ago,
>> several bugs have appeared about the processing of these integers by
>> other Scilab functions, noticeably some functions involved in the
>> bitget implementation.
>> Not all are fixed (actually, only few of them are fixed).
>> But maybe it's another issue here. I could have a look, about this
>> specific case.
>>
>> If you can do other tests and get issues, please report all of them
>> on bugzilla.
>> Thanks
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200227/b46c0cc8/attachment.htm>
More information about the users
mailing list