View source code
							
							
						
								Display the source code in std/bigint.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								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.
							
						Function std.bigint.BigInt.opCmp
Implements 3-way comparisons of BigInt with BigInt or BigInt with
        built-in numeric types.
						
				int opCmp
				(
				
				  ref const(BigInt) y
				
				) pure nothrow @nogc @safe const;
				
				
				int opCmp(T)
				(
				
				  const T y
				
				) const pure nothrow @nogc @safe
				
				if (isIntegral!T);
				
				
				int opCmp(T)
				(
				
				  const T y
				
				) const nothrow @nogc @safe
				
				if (isFloatingPoint!T);
				
				
				int opCmp(T)
				(
				
				  const T y
				
				) const pure nothrow @nogc @safe;
						
					
				Example
auto x = BigInt("100");
auto y = BigInt("10");
int z = 50;
const int w = 200;
assert(y < x);
assert(x > z);
assert(z > y);
assert(x < w);
Example
auto x = BigInt("0x1abc_de80_0000_0000_0000_0000_0000_0000");
BigInt y = x - 1;
BigInt z = x + 1;
double d = 0x1.abcde8p124;
assert(y < d);
assert(z > d);
assert(x >= d && x <= d);
// Note that when comparing a BigInt to a float or double the
// full precision of the BigInt is always considered, unlike
// when comparing an int to a float or a long to a double.
assert(BigInt(123456789) < cast(float) 123456789);
Authors
Don Clugston
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.