Re: [Scilab-users] Bitget for int64/uint64

2020-02-28 Thread Samuel Gougeon
Le 28/02/2020 à 18:14, Jan Åge Langeland a écrit : Thank you Samuel For some reason I get an error message : --> genlib elementary_functionslib genlib: Cannot open file ''C:\Program Files\scilab-6.1.0\modules\elementary_functions\macros\lib''.  ans  =  F Although scinotes("lib") opens the f

Re: [Scilab-users] Bitget for int64/uint64

2020-02-28 Thread Jan Åge Langeland
Thank you Samuel For some reason I get an error message : --> genlib elementary_functionslib genlib: Cannot open file ''C:\Program Files\scilab-6.1.0\modules\elementary_functions\macros\lib''.  ans  =  F Although scinotes("lib") opens the file, so it is there. Anyway, this works fine: --> e

Re: [Scilab-users] Bitget for int64/uint64

2020-02-28 Thread Samuel Gougeon
Hello Jan, You will find => there a fixed version of bitget() for big u-int64 integers. You can patch your Scilab 6.1.0 installation in the following way: * download and unzip the file. rena

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Samuel Gougeon
Le 27/02/2020 à 17:44, Jan Åge Langeland a écrit : A bit of a waste to use uint64 to store single bits, but that is what bitget does: --> typeof(bb1)  ans  =  "uint64" This is not worse than returning always decimal numbers 0. and 1. And better than returning booleans, for u-int8 and u-int16

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Samuel Gougeon
With the current implementation, you will get the right result with the following: bitget([b b], uint64(1:64))(1,:) * use a non scalar x (pad it with anything if scalar) * use a non scalar pos (idem) * use a pos with the same int64 or uint64 type than x Samuel Le 27/02/2020 à 16:17, JLan a

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Jan Åge Langeland
Thank you, Stéphane So a workaround is: 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

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Samuel Gougeon
OK, there is a trivial work-around for bitget(). I will post the URL of the fixed macro and how-to fix it for your own 6.1.0 as soon as put on the forge. I will also add actual examples with integers in the page, and fix minor typos. Samuel Le 27/02/2020 à 17:51, Samuel Gougeon a écrit : A

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Jan Åge Langeland
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: --> type

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Samuel Gougeon
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 wil

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Samuel Gougeon
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(

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Stéphane Mottelet
But the problem with bitget remains. The new bitstring is ok: --> bitstring(a)  ans  = "0010" --> bitstring(a+1)  ans  = "0011" S. Le 27/02/2020 à 16:37, Stéphane Mottelet

Re: [Scilab-users] Bitget for int64/uint64

2020-02-27 Thread Stéphane Mottelet
You should generate big ints like this: a=uint64(2)^61 S. 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 = 230584300921369395

[Scilab-users] Bitget for int64/uint64

2020-02-27 Thread JLan
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(a,1:64) ans = column 1 to 32