-
-
Notifications
You must be signed in to change notification settings - Fork 748
Fix Issue 17249: Added BigInt.getDigit #5987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| `getDigit` Was Added To `std.bigint` | ||
|
|
||
| $(REF getDigit, std, algorithm, BigInt) gives the `ulongs` or `uints` | ||
| that make up the underlying representation of the `BigInt`. | ||
|
|
||
| ----- | ||
| import std.bigint; | ||
|
|
||
| auto a = BigInt("1000"); | ||
| assert(a.getDigit(0) == 1000); | ||
|
|
||
| auto b = BigInt("2_000_000_000_000_000_000_000_000_000"); | ||
| assert(b.getDigit(0) == 4584946418820579328); | ||
| assert(b.getDigit(1) == 108420217); | ||
| ----- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,7 +144,7 @@ public: | |
| } | ||
|
|
||
| // The value at (cast(ulong[]) data)[n] | ||
| ulong peekUlong(int n) pure nothrow const @safe @nogc | ||
| ulong peekUlong(size_t n) pure nothrow const @safe @nogc | ||
| { | ||
| static if (BigDigit.sizeof == int.sizeof) | ||
| { | ||
|
|
@@ -156,7 +156,8 @@ public: | |
| return data[n]; | ||
| } | ||
| } | ||
| uint peekUint(int n) pure nothrow const @safe @nogc | ||
|
|
||
| uint peekUint(size_t n) pure nothrow const @safe @nogc | ||
| { | ||
| static if (BigDigit.sizeof == int.sizeof) | ||
| { | ||
|
|
@@ -168,7 +169,7 @@ public: | |
| return (n & 1) ? cast(uint)(x >> 32) : cast(uint) x; | ||
| } | ||
| } | ||
| public: | ||
|
|
||
| /// | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this removed because the following method wasn't intended to be public? Also, does this change somehow relate to this PR?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Public is already set a couple of lines above. It's pretty redundant and I don't think it's a problem to include such small things if they are trivial.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. Though I'm starting to agree with @andralex that |
||
| void opAssign(Tulong)(Tulong u) pure nothrow @safe if (is (Tulong == ulong)) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd think ushort and ubyte would also be useful, but can be added later.