Bug 10387 – BigInt lacks opBinary overloads for bitwise operators
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-16T21:28:00Z
Last change time
2013-11-07T07:42:47Z
Assigned to
nobody
Creator
ridimz
Comments
Comment #0 by ridimz — 2013-06-16T21:28:28Z
Attempting to apply the bitwise operators to BigInt values results
compile time error.
Steps to reproduce:
void main()
{
import std.bigint;
import std.stdio;
auto x = BigInt(2), m = BigInt(11);
auto x1 = x & m;
auto x2 = x | m;
auto x3 = x ^ m;
writeln("x1 = ", x1, " x2 = ", x2, " x3 = ", x3);
x = BigInt(5), m = BigInt(27);
x1 = x & m;
x2 = x | m;
x3 = x ^ m;
writeln("x1 = ", x1, " x2 = ", x2, " x3 = ", x3);
x = BigInt(2), m = BigInt(18);
x1 = x & m;
x2 = x | m;
x3 = x ^ m;
writeln("x1 = ", x1, " x2 = ", x2, " x3 = ", x3);
}
Actual results:
andrew@ace:~$ dmd bw
bw.d(7): Error: 'x' is not of integral type, it is a BigInt
bw.d(7): Error: 'm' is not of integral type, it is a BigInt
bw.d(8): Error: 'x' is not of integral type, it is a BigInt
bw.d(8): Error: 'm' is not of integral type, it is a BigInt
bw.d(9): Error: 'x' is not of integral type, it is a BigInt
bw.d(9): Error: 'm' is not of integral type, it is a BigInt
bw.d(13): Error: 'x' is not of integral type, it is a BigInt
bw.d(13): Error: 'm' is not of integral type, it is a BigInt
bw.d(14): Error: 'x' is not of integral type, it is a BigInt
bw.d(14): Error: 'm' is not of integral type, it is a BigInt
bw.d(15): Error: 'x' is not of integral type, it is a BigInt
bw.d(15): Error: 'm' is not of integral type, it is a BigInt
bw.d(19): Error: 'x' is not of integral type, it is a BigInt
bw.d(19): Error: 'm' is not of integral type, it is a BigInt
bw.d(20): Error: 'x' is not of integral type, it is a BigInt
bw.d(20): Error: 'm' is not of integral type, it is a BigInt
bw.d(21): Error: 'x' is not of integral type, it is a BigInt
bw.d(21): Error: 'm' is not of integral type, it is a BigInt
Expected results:
x1 = 2 x2 = 11 x3 = 9
x1 = 1 x2 = 31 x3 = 30
x1 = 2 x2 = 18 x3 = 16
DMD64 D Compiler v2.064-devel-22a06f8 on Mac OS 10.8.4
Comment #1 by simen.kjaras — 2013-11-07T07:42:47Z
*** This issue has been marked as a duplicate of issue 9061 ***