View source code
Display the source code in std/bigint.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
std.bigint.big_int.op_binary
- multiple declarations
- Function BigInt.opBinary
- Function BigInt.opBinary
- Function BigInt.opBinary
Function BigInt.opBinary
Implements binary operators between BigInts.
Prototype
BigInt opBinary(string op, T)( T y ) const pure nothrow if ((op == "+" || op == "*" || op == "-" || op == "|" || op == "&" || op == "^" || op == "/" || op == "%") && is(T : BigInt));
Example
auto x = BigInt("123"); auto y = BigInt("456"); BigInt z = x * y; assert(z == BigInt("56088"));
Function BigInt.opBinary
Implements binary operators between BigInt
's and built-in integers.
Prototype
BigInt opBinary(string op, T)( T y ) const pure nothrow if ((op == "+" || op == "*" || op == "-" || op == "/" || op == "|" || op == "&" || op == "^" || op == ">>" || op == "<<" || op == "^^") && isIntegral!T);
Example
auto x = BigInt("123"); x *= 300; assert(x == BigInt("36900"));
Function BigInt.opBinary
Implements a narrowing remainder operation with built-in integer types.
This binary operator returns a narrower, built-in integer type where applicable, according to the following table.
| % | long | → | long |
| % | ulong | → |
|
| % | other type | → | int |
Prototype
auto nothrow opBinary(string op, T)( T y ) const pure if (op == "%" && isIntegral!T);
Example
auto x = BigInt("1_000_000_500"); long l = 1_000_000L; ulong ul = 2_000_000UL; int i = 500_000; short s = 30_000; assert(is(typeof(x % l) == long) && x % l == 500L); assert(is(typeof(x % ul) == BigInt) && x % ul == BigInt(500)); assert(is(typeof(x % i) == int) && x % i == 500); assert(is(typeof(x % s) == int) && x % s == 10500);
Authors
Don Clugston