bitget(u-int64) fixed & examples added 21/21421/6
Samuel GOUGEON [Fri, 28 Feb 2020 02:18:30 +0000 (03:18 +0100)]
  http://mailinglists.scilab.org/Scilab-users-Bitget-for-int64-uint64-tt4040422.html

Change-Id: I7e4a0731dfe81861158c62afbdaf3ddc7002bc8c

scilab/modules/elementary_functions/help/en_US/bitwise/bitget.xml
scilab/modules/elementary_functions/help/ru_RU/bitwise/bitget.xml
scilab/modules/elementary_functions/macros/bitget.sci
scilab/modules/elementary_functions/tests/unit_tests/bitget.tst

index ea2aa72..7ad0377 100644 (file)
@@ -3,9 +3,8 @@
  *
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2011 - DIGITEO - Michael Baudin
- * Copyright (C) 2017 - Samuel GOUGEON
- *
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2017 - 2020 - Samuel GOUGEON
  *
  * This file is hereby licensed under the terms of the GNU GPL v2.0,
  * pursuant to article 5.3.4 of the CeCILL v.2.1.
             <varlistentry>
                 <term>x</term>
                 <listitem>
-                    <para>
-                        Scalar, vector, matrix or hypermatrix of positive decimal or encoded integers.
-                    </para>
+                    Scalar, vector, matrix or hypermatrix of positive decimal or encoded integers.
+                    <para/>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>pos</term>
                 <listitem>
-                    <para>
-                        Scalar, vector, matrix or hypermatrix of decimal or encoded integers in
-                        <literal>[1, bitmax]</literal> where <literal>bitmax</literal> is the
-                        maximal index of bits for the type of <varname>x</varname>: Indices of bits
-                        to be extracted. The bit #1 is the lightest one (2<superscript>0</superscript>).
+                    Scalar, vector, matrix or hypermatrix of decimal or encoded integers in
+                    <literal>[1, bitmax]</literal> where <literal>bitmax</literal> is the
+                    maximal index of bits for the type of <varname>x</varname>: Indices of bits
+                    to be extracted. The bit #1 is the lightest one (2<superscript>0</superscript>).
             <table>
                 <tr><th>typeof(x)</th><th>bitmax</th><td>..</td><th>typeof(x)</th><th>bitmax</th></tr>
                 <tr align="center"><td>int8  </td><td>7</td> <td>  </td><td>uint8</td><td>8</td></tr>
                 <tr align="center"><td>int16 </td><td>15</td><td>  </td><td>uint16</td><td>16</td></tr>
                 <tr align="center"><td>int32 </td><td>31</td><td>  </td><td>uint32</td><td>32</td></tr>
-                <tr align="center"><td>int64 </td><td>63</td><td>  </td><td>uint16</td><td>64</td></tr>
+                <tr align="center"><td>int64 </td><td>63</td><td>  </td><td>uint64</td><td>64</td></tr>
                 <tr align="center"><td>decimal</td><td>1024</td><td>  </td><td></td><td></td></tr>
             </table>
-                    </para>
+                    <para/>
                 </listitem>
             </varlistentry>
             <varlistentry>
                         Scalar, vector, matrix or hypermatrix of 0 and 1 of the type of
                         <varname>x</varname>. The sizes and contents of <varname>y</varname> are
                         as follows:
+                    </para>
+                    <para>
+                        <emphasis role="bold">If <varname>x</varname> is a scalar</emphasis>:
+                        <itemizedlist>
+                            <listitem>
+                                <varname>y</varname> has the sizes of <varname>pos</varname>
+                            </listitem>
+                            <listitem>
+                                <literal>y(i,j,..)</literal> is the value of bit
+                                #<literal>pos(i,j,..)</literal> of <varname>x</varname>.
+                            </listitem>
+                        </itemizedlist>
+                    </para>
+                    <para>
+                        <emphasis role="bold">If <varname>pos</varname> is a scalar</emphasis>:
+                        <itemizedlist>
+                            <listitem>
+                                <varname>y</varname> has the sizes of <varname>x</varname>
+                            </listitem>
+                            <listitem>
+                                <literal>y(i,j,..)</literal> is the value of the bit
+                                #<literal>pos</literal> of <literal>x(i,j,..)</literal>.
+                            </listitem>
+                        </itemizedlist>
+                    </para>
+                    <para>
+                        <emphasis role="bold">If <varname>x</varname> and <varname>pos</varname>
+                        are arrays with identical sizes</emphasis>, the processing is element-wise:
                         <itemizedlist>
                             <listitem>
-                                <para>
-                                If <varname>x</varname> is a scalar:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> has the sizes of <varname>pos</varname>
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j,..)</literal> is the value of bit
-                                        #<literal>pos(i,j,..)</literal> of <varname>x</varname>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <varname>y</varname> has the sizes of <varname>x</varname>
+                                and <varname>pos</varname>
                             </listitem>
                             <listitem>
-                                <para>
-                                If <varname>pos</varname> is a scalar:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> has the sizes of <varname>x</varname>
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j,..)</literal> is the value of the bit
-                                        #<literal>pos</literal> of <literal>x(i,j,..)</literal>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <literal>y(i,j,..)</literal> is the value of the bit
+                                #<literal>pos(i,j,..)</literal> of <literal>x(i,j,..)</literal>.
                             </listitem>
+                        </itemizedlist>
+                    </para>
+                    <para>
+                        <emphasis role="bold">Otherwise</emphasis>:
+                        <itemizedlist>
                             <listitem>
-                                <para>
-                                If <varname>x</varname> and <varname>pos</varname> are arrays with
-                                identical sizes, the processing is element-wise:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> has the sizes of <varname>x</varname>
-                                        and <varname>pos</varname>
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j,..)</literal> is the value of the bit
-                                        #<literal>pos(i,j,..)</literal> of <literal>x(i,j,..)</literal>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <varname>y</varname> is a matrix with
+                                <literal>length(x)</literal> rows and
+                                <literal>length(pos)</literal> columns.
                             </listitem>
                             <listitem>
-                                <para>Otherwise:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> is a matrix with
-                                        <literal>length(x)</literal> rows and
-                                        <literal>length(pos)</literal> columns.
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j)</literal> is the value of the bit
-                                        #<literal>pos(j)</literal> of <literal>x(i)</literal>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <literal>y(i,j)</literal> is the value of the bit
+                                #<literal>pos(j)</literal> of <literal>x(i)</literal>.
                             </listitem>
                         </itemizedlist>
                     </para>
         <programlisting role="example"><![CDATA[
 // 19 is (10011)_2
 // The 2nd bit is 1 (starting from the end).
-x=uint8(19);
-pos=2;
+x = uint8(19);
+pos = 2;
 y = bitget(x,pos)
 expected = 1;
 
@@ -166,20 +154,76 @@ dec2bin(13)
 bitget(uint8(13),4:-1:1)
    ]]></programlisting>
         <para>
-        <emphasis role="bold">With arrays and encoded integers:</emphasis>:
+            <emphasis role="bold">With encoded integers</emphasis>:
         </para>
         <programlisting role="example"><![CDATA[
-
+b = [1 3 8 11 15];
+x = sum(int16(2).^(b-1))
+B = bitget(x, 1:15)
+find(B)
+typeof(B)
    ]]></programlisting>
         <screen><![CDATA[
+--> b = [1 3 8 11 15];
+--> x = sum(int16(2).^(b-1))
+ x  =
+  17541
+
+--> B = bitget(x, 1:15)
+ B  =
+  1  0  1  0  0  0  0  1  0  0  1  0  0  0  1
+
+--> find(B)
+ ans  =
+   1.   3.   8.   11.   15.
+
+--> typeof(B)
+ ans  =
+  "int16"
+]]></screen>
+        <para>
+            <emphasis role="bold">
+                With uint64 integers > 2<superscript>52</superscript>
+            </emphasis>:
+        </para>
+        <programlisting role="example"><![CDATA[
+b = [1 12 23 34 45 53 64];
+x = sum(uint64(2).^(b-1))
+B = bitget(x, 1:64)
+find(B)
+typeof(B)
+     ]]></programlisting>
+        <screen><![CDATA[
+--> b = [1 12 23 34 45 53 64];
+--> x = sum(uint64(2).^(b-1))
+ x  =
+  9227893237262321665
+
+--> B = bitget(x, 1:64)
+ B  =
+         column 1 to 32
+ 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
+
+         column 33 to 64
+ 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
+
+--> find(B)
+ ans  =
+   1.   12.   23.   34.   45.   53.   64.
+
+--> typeof(B)
+ ans  =
+  "uint64"
 ]]></screen>
         <para>
-        <emphasis role="bold">With big decimal integers > 2<superscript>52</superscript></emphasis>:
+            <emphasis role="bold">
+                With big decimal integers > 2<superscript>52</superscript>
+            </emphasis>:
         </para>
         <programlisting role="example"><![CDATA[
 x = sum(2 .^([7 16 18 19 25 52 70]-1))
 bitget(x,    [7 16 18 19 35 52 70 80])
-   ]]></programlisting>
+     ]]></programlisting>
         <screen><![CDATA[
 --> x = sum(2 .^([7 16 18 19 25 52 70]-1))
  x  =
@@ -190,7 +234,7 @@ bitget(x,    [7 16 18 19 35 52 70 80])
    Nan   Nan   1.   1.   0.   1.   1.   0.
 ]]></screen>
         <para>
-        <emphasis role="bold">x and pos are arrays with mismatching sizes:</emphasis>
+            <emphasis role="bold">x and pos are arrays with mismatching sizes:</emphasis>
         </para>
         <programlisting role="example"><![CDATA[
 x = [ 39  6   62
@@ -201,8 +245,8 @@ x = [ 39  6   62
       5   4   29 ];
 x = sum(2.^(x-1),2);
 bitget(x, [5 8 12 39])
-   ]]></programlisting>
-   <screen><![CDATA[
+      ]]></programlisting>
+         <screen><![CDATA[
 --> bitget(x, [5 8 12 39])
  ans  =
    Nan   Nan   0.   1.
@@ -241,7 +285,7 @@ bitget(x, [5 8 12 39])
                 <revdescription>
                     <itemizedlist>
                         <listitem>
-                            Positive unsigned integers are now accepted.
+                            Positive signed integers are now accepted.
                         </listitem>
                         <listitem>
                             64 bits encoded integers are now accepted.
index 3a985fa..0c6cb84 100644 (file)
             <varlistentry>
                 <term>x</term>
                 <listitem>
-                    <para>
-                        Скаляр, вектор, матрица или гиперматрица положительных десятичных или
-                        кодированных целых чисел.
-                    </para>
+                    Скаляр, вектор, матрица или гиперматрица положительных десятичных или
+                    кодированных целых чисел.
+                    <para/>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>pos</term>
                 <listitem>
-                    <para>
-                        Скаляр, вектор, матрица или гиперматрица десятичных или кодированных целых чисел в
-                        <literal>[1, bitmax]</literal>, где <literal>bitmax</literal> - это максимальный
-                        индекс битов для типа переменной <varname>x</varname>: индексы битов, которые
-                        следует извлечь. Бит №1 - это наименьший бит  (2<superscript>0</superscript>).
+                    Скаляр, вектор, матрица или гиперматрица десятичных или кодированных целых чисел в
+                    <literal>[1, bitmax]</literal>, где <literal>bitmax</literal> - это максимальный
+                    индекс битов для типа переменной <varname>x</varname>: индексы битов, которые
+                    следует извлечь. Бит №1 - это наименьший бит  (2<superscript>0</superscript>).
             <table>
                 <tr><th>typeof(x)</th><th>bitmax</th><td>..</td><th>typeof(x)</th><th>bitmax</th></tr>
                 <tr align="center"><td>int8  </td><td>7</td> <td>  </td><td>uint8</td><td>8</td></tr>
                 <tr align="center"><td>int16 </td><td>15</td><td>  </td><td>uint16</td><td>16</td></tr>
                 <tr align="center"><td>int32 </td><td>31</td><td>  </td><td>uint32</td><td>32</td></tr>
-                <tr align="center"><td>int64 </td><td>63</td><td>  </td><td>uint16</td><td>64</td></tr>
+                <tr align="center"><td>int64 </td><td>63</td><td>  </td><td>uint64</td><td>64</td></tr>
                 <tr align="center"><td>десятичное число</td><td>1024</td><td>  </td><td></td><td></td></tr>
             </table>
-                    </para>
+                    <para/>
                 </listitem>
             </varlistentry>
             <varlistentry>
                     <para>
                         Скаляр, вектор, матрица или гиперматрица из 0 и 1 типа переменной
                         <varname>x</varname>. Размеры и содержимое <varname>y</varname> следующие:
+                    </para>
+                    <para>
+                        <emphasis role="bold">Если <varname>x</varname> скаляр</emphasis>:
+                        <itemizedlist>
+                            <listitem>
+                                <varname>y</varname> имеет размеры <varname>pos</varname>
+                            </listitem>
+                            <listitem>
+                                <literal>y(i,j,..)</literal> - это значение бита
+                                №<literal>pos(i,j,..)</literal> переменной <varname>x</varname>.
+                            </listitem>
+                        </itemizedlist>
+                    </para>
+                    <para>
+                        <emphasis role="bold">Если <varname>pos</varname> скаляр</emphasis>:
+                        <itemizedlist>
+                            <listitem>
+                                <varname>y</varname> имеет размеры <varname>x</varname>
+                            </listitem>
+                            <listitem>
+                                <literal>y(i,j,..)</literal> - это значение бита
+                                №<literal>pos</literal> в <literal>x(i,j,..)</literal>.
+                            </listitem>
+                        </itemizedlist>
+                    </para>
+                    <para>
+                        <emphasis role="bold">Если <varname>x</varname> и <varname>pos</varname>
+                        являются  массивами одинаковых размеров</emphasis>,
+                        то обработка идёт поэлементно:
                         <itemizedlist>
                             <listitem>
-                                <para>
-                                Если <varname>x</varname> скаляр:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> имеет размеры <varname>pos</varname>
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j,..)</literal> - это значение бита
-                                        №<literal>pos(i,j,..)</literal> переменной <varname>x</varname>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <varname>y</varname> имеет размеры <varname>x</varname>
+                                и <varname>pos</varname>
                             </listitem>
                             <listitem>
-                                <para>
-                                Если <varname>pos</varname> скаляр:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> имеет размеры <varname>x</varname>
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j,..)</literal> - это значение бита
-                                        №<literal>pos</literal> в <literal>x(i,j,..)</literal>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <literal>y(i,j,..)</literal> - это значение бита
+                                №<literal>pos(i,j,..)</literal> в <literal>x(i,j,..)</literal>.
                             </listitem>
+                        </itemizedlist>
+                    </para>
+                    <para>
+                        <emphasis role="bold">В противном случае</emphasis>:
+                        <itemizedlist>
                             <listitem>
-                                <para>
-                                Если <varname>x</varname> и <varname>pos</varname> являются  массивами
-                                одинаковых размеров, то обработка идёт поэлементно:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> имеет размеры <varname>x</varname>
-                                        и <varname>pos</varname>
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j,..)</literal> - это значение бита
-                                        №<literal>pos(i,j,..)</literal> в <literal>x(i,j,..)</literal>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <varname>y</varname> - это матрица, у которой
+                                <literal>length(x)</literal> строк и
+                                <literal>length(pos)</literal> столбцов.
                             </listitem>
                             <listitem>
-                                <para>В противном случае:
-                                <itemizedlist>
-                                    <listitem>
-                                        <varname>y</varname> - это матрица, у которой
-                                        <literal>length(x)</literal> строк и
-                                        <literal>length(pos)</literal> столбцов.
-                                    </listitem>
-                                    <listitem>
-                                        <literal>y(i,j)</literal> - это значение бита
-                                        №<literal>pos(j)</literal> в <literal>x(i)</literal>.
-                                    </listitem>
-                                </itemizedlist>
-                                </para>
+                                <literal>y(i,j)</literal> - это значение бита
+                                №<literal>pos(j)</literal> в <literal>x(i)</literal>.
                             </listitem>
                         </itemizedlist>
                     </para>
@@ -166,14 +156,69 @@ dec2bin(13)
 bitget(uint8(13),4:-1:1)
    ]]></programlisting>
         <para>
-        <emphasis role="bold">С массивами и кодированными целыми числами:</emphasis>:
+            <emphasis role="bold">С кодированными целыми числами</emphasis>:
         </para>
         <programlisting role="example"><![CDATA[
+b = [1 3 8 11 15];
+x = sum(int16(2).^(b-1))
+B = bitget(x, 1:15)
+find(B)
+typeof(B)
    ]]></programlisting>
         <screen><![CDATA[
+--> b = [1 3 8 11 15];
+--> x = sum(int16(2).^(b-1))
+ x  =
+  17541
+
+--> B = bitget(x, 1:15)
+ B  =
+  1  0  1  0  0  0  0  1  0  0  1  0  0  0  1
+
+--> find(B)
+ ans  =
+   1.   3.   8.   11.   15.
+
+--> typeof(B)
+ ans  =
+  "int16"
+]]></screen>
+        <para>
+            <emphasis role="bold">
+                С целыми числами типа uint64 больше 2<superscript>52</superscript>
+            </emphasis>:
+        </para>
+        <programlisting role="example"><![CDATA[
+b = [1 12 23 34 45 53 64];
+x = sum(uint64(2).^(b-1))
+B = bitget(x, 1:64)
+find(B)
+typeof(B)
+     ]]></programlisting>
+        <screen><![CDATA[
+--> b = [1 12 23 34 45 53 64];
+--> x = sum(uint64(2).^(b-1))
+ x  =
+  9227893237262321665
+
+--> B = bitget(x, 1:64)
+ B  =
+         column 1 to 32
+ 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
+
+         column 33 to 64
+ 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
+
+--> find(B)
+ ans  =
+   1.   12.   23.   34.   45.   53.   64.
+
+--> typeof(B)
+ ans  =
+  "uint64"
 ]]></screen>
         <para>
-        <emphasis role="bold">С большими десятичными целыми числами > 2<superscript>52</superscript></emphasis>:
+        <emphasis role="bold">С большими десятичными целыми числами больше 2<superscript>52</superscript></emphasis>:
         </para>
         <programlisting role="example"><![CDATA[
 x = sum(2 .^([7 16 18 19 25 52 70]-1))
@@ -240,7 +285,7 @@ bitget(x, [5 8 12 39])
                 <revdescription>
                     <itemizedlist>
                         <listitem>
-                            Теперь принимаются положительные беззнаковые целые числа.
+                            Теперь принимаются положительные знаковые целые числа.
                         </listitem>
                         <listitem>
                             Теперь принимаются 64-битные кодированные целые числа.
index 7480482..79a5ce2 100644 (file)
@@ -1,8 +1,8 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) ???? - INRIA - Farid BELAHCENE
 // Copyright (C) 2008 - INRIA - Pierre MARECHAL
-// Copyright (C) 2017 - Samuel GOUGEON
 // Copyright (C) 2012 - 2016 - Scilab Enterprises
+// Copyright (C) 2017 - 2020 - Samuel GOUGEON
 //
 // This file is hereby licensed under the terms of the GNU GPL v2.0,
 // pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -56,10 +56,10 @@ function z = bitget(x, pos)
     // check sizes
     fromEach = length(x)>1 & length(pos)>1 & (or(size(x)<>size(pos)));
     if size(x,"*") == 1
-        x = ones(pos) * x;
+        x = x(ones(pos))
     end
     if size(pos,"*") == 1
-        pos = ones(x) * pos;
+        pos = pos(ones(x));
     end
 
     // check pos value
@@ -82,26 +82,25 @@ function z = bitget(x, pos)
     // PROCESSING
     // ==========
     if fromEach then
-        masks = 2.^(pos-1);
+        masks = 2 .^ iconvert(pos-1, inttype(x));
         [X,B] = ndgrid(x(:), masks);
         z = bool2s(bitand(X,B)==B);
         if type(x)==1
             [X,B] = ndgrid(x(:), pos);
-            below_eps = B<=(log2(X)-52);
+            below_eps = B <= (log2(X)-52);
             z(below_eps) = %nan;
         else
             z = iconvert(z, inttype(x));
         end
     else
-        if  type(x)==8
-            mask = iconvert(2 .^(pos-1), inttype(x));
+        if type(x)==8
+            mask = 2 .^ iconvert(pos-1, inttype(x));
             z = iconvert(1 * ((x & mask) > 0),inttype(x));
         else
-            tmp = x ./ (2 .^pos);
-            z = bool2s((tmp - fix(tmp))>=0.5);
-            below_eps = pos<=(log2(x)-52);
+            tmp = x ./ (2 .^ pos);
+            z = bool2s((tmp - fix(tmp)) >= 0.5);
+            below_eps = pos <= (log2(x)-52);
             z(below_eps) = %nan;
         end
     end
 endfunction
-
index 32c7284..1bd7b14 100644 (file)
@@ -1,16 +1,16 @@
-// =============================================================================
+// ===================================================================
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
 // Copyright (C) 2017 - Samuel GOUGEON
 //
 //  This file is distributed under the same license as the Scilab package.
-// =============================================================================
+// ===================================================================
 
 // <-- CLI SHELL MODE -->
 // <-- NO CHECK REF -->
 
 // Test 1
-// =============================================================================
+// ===================================================================
 // Test 1.1
 A = floor(2^52 * rand(20,20));
 for i=1:size(A,"*");
@@ -32,7 +32,7 @@ for i = [1 2 4 8 11 12 14 18]               // Loop on int types
 end
 
 // Test 2
-// =============================================================================
+// ===================================================================
 A0 = bin2dec(["0001" "0010";"0011" "0100"]);
 B =         [    1      0 ;    1      0 ];
 C =         [   0      1  ;   1      0  ];
@@ -43,7 +43,7 @@ for i = [0 1 2 4 8 11 12 14 18]
 end
 
 // Test 3: about bitmax
-// =============================================================================
+// ===================================================================
 k = [0 1 2 4 8 11 12 14 18];
 bitmax = [1024 7 15 31 63 8 16 32 64];
 for i = 1:length(k)
@@ -54,7 +54,7 @@ for i = 1:length(k)
 end
 
 // Tests about input / output types
-// =============================================================================
+// ===================================================================
 it = [0 1 2 4 8 11 12 14 18];
 for i = it
     n = abs(iconvert([1 10 100 271 1000 3467 34567], i));
@@ -65,7 +65,7 @@ for i = it
 end
 
 // Tests about input / output sizes
-// =============================================================================
+// ===================================================================
 b = [1 3 4 6 7];
 n = sum(2^(b-1));
 
@@ -111,7 +111,7 @@ ref = [
 assert_checkequal(bitget(x, [5 8 12 39]), ref);
 
 // Bits extraction from decimal numbers > 2^52
-// =============================================================================
+// ===================================================================
 assert_checkequal(execstr("bitget(123 , 54);","errcatch"), 0);
 assert_checkequal(execstr("bitget(123 , 1000);","errcatch"), 0);
 
@@ -135,3 +135,51 @@ va = sum(2 .^(bg(s).*(i(s)-1)));
 assert_checkequal(va, v);
 
 
+// Big int64 and uint64 integers > 2^53
+// ===================================================================
+// uint64
+// ------
+// x scalar, all bits
+for i = 1:5
+    bref = find(grand(1, 64, "uin", 0, 1))';
+    x = bitset(uint64(0), bref);
+    b = bitget(x, 1:64);
+    assert_checkequal(find(b)', bref);
+    assert_checkequal(inttype(b), inttype(x));
+end
+// x column, bits 1:64
+n = 20;
+bref = grand(n, 64, "uin", 0, 1);
+bin = bref .* (ones(n, 1) * (1:64));
+x = [];
+for i = 1:n
+    x = [ x ; bitset(uint64(0), find(bin(i,:))) ];
+end
+assert_checkequal(bitget(x, 1:64), uint64(bref));
+// Element-wise extraction
+for i = 1:64
+    assert_checkequal(bitget(x, i*ones(n,1)), uint64(bref(:,i)));
+end
+
+// int64
+// -----
+for i = 1:5
+    bref = find(grand(1, 63, "uin", 0, 1))';
+    x = bitset(int64(0), bref);
+    b = bitget(x, 1:63);
+    assert_checkequal(find(b)', bref);
+    assert_checkequal(inttype(b), inttype(x));
+end
+// x column, bits 1:64
+n = 20;
+bref = grand(n,63, "uin", 0, 1);
+bin = bref .* (ones(n,1)*(1:63));
+x = [];
+for i = 1:n
+    x = [x ; bitset(int64(0), find(bin(i,:)))];
+end
+assert_checkequal(bitget(x,1:63), int64(bref));
+// Element-wise extraction
+for i = 1:63
+    assert_checkequal(bitget(x,i*ones(n,1)), int64(bref(:,i)));
+end