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.
std.bigint.BigInt.this
- multiple declarations
Function BigInt.this
Construct a BigInt
from a decimal or hexadecimal string. The number must
be in the form of a decimal or hex literal. It may have a leading +
or -
sign, followed by 0x
or 0X
if hexadecimal. Underscores are
permitted in any location after the 0x
and/or the sign of the number.
this(Range)
(
Range s
)
if (isBidirectionalRange!Range && isSomeChar!(ElementType!Range) && !isInfinite!Range && !isNarrowString!Range);
this(Range)
(
Range s
) pure
if (isNarrowString!Range);
Parameters
Name | Description |
---|---|
s | a finite bidirectional range of any character type |
Throws
ConvException
if the string doesn't represent a valid number
Function BigInt.this
Construct a BigInt
from a sign and a magnitude.
this(Range)
(
bool isNegative,
Range magnitude
)
if (isInputRange!Range && isUnsigned!(ElementType!Range) && (hasLength!Range || isForwardRange!Range) && !isInfinite!Range);
The magnitude is an input range
of unsigned integers that satisfies either hasLength
or isForwardRange
. The first (leftmost)
element of the magnitude is considered the most significant.
Parameters
Name | Description |
---|---|
isNegative | true for negative, false for non-negative (ignored when magnitude is zero) |
magnitude | a finite range of unsigned integers |
Example
ubyte[] magnitude = [1, 2, 3, 4, 5, 6];
auto b1 = BigInt(false, magnitude);
writeln(cast(long)b1); // 0x01_02_03_04_05_06L
auto b2 = BigInt(true, magnitude);
writeln(cast(long)b2); // -0x01_02_03_04_05_06L
Function BigInt.this
Construct a BigInt
from a built-in integral type.
this(T)
(
T x
) pure nothrow @safe
if (isIntegral!T);
Example
ulong data = 1_000_000_000_000;
auto bigData = BigInt(data);
writeln(bigData); // BigInt("1_000_000_000_000")
Function BigInt.this
Construct a BigInt
from another BigInt
.
this(T)
(
T x
) pure nothrow @safe
if (is(immutable(T) == immutable(BigInt)));
Example
const(BigInt) b1 = BigInt("1_234_567_890");
BigInt b2 = BigInt(b1);
writeln(b2); // BigInt("1_234_567_890")
Authors
Don Clugston
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.