Fix Issue 17249: Added BigInt.getDigit#5987
Conversation
|
Thanks for your pull request, @JackStouffer! Bugzilla references
|
80206a2 to
a59365e
Compare
std/bigint.d
Outdated
| * Returns: | ||
| * The nth `ulong` in the representation of this `BigInt`. | ||
| */ | ||
| ulong ulongDigit(int n) pure nothrow const @safe @nogc |
There was a problem hiding this comment.
How about using only one functions?
Something lilke:
Type digit(Type)(size_t n)Usage:
BigInt(20).digit!ulong(0).a59365e to
5ad7100
Compare
|
@wilzbach done |
std/bigint.d
Outdated
| * The nth `ulong` in the representation of this `BigInt`. | ||
| */ | ||
| T getDigit(T = ulong)(size_t n) const | ||
| if (is(T == ulong) || is(T == uint)) |
There was a problem hiding this comment.
Constraint indentation should be on the same level... I thought there was a test for this :/
There was a problem hiding this comment.
dlang-community/D-Scanner#450 - it just never made it into DScanner.
5ad7100 to
dae55d0
Compare
| } | ||
| public: | ||
|
|
||
| /// |
There was a problem hiding this comment.
Was this removed because the following method wasn't intended to be public? Also, does this change somehow relate to this PR?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Fair enough.
Though I'm starting to agree with @andralex that private should be attached per declaration rather than wholesale, for better context when reading the code. But that's for another day.
|
ping @andralex This one has been rotting here for a while. Let's move it forward! |
| * The nth `ulong` in the representation of this `BigInt`. | ||
| */ | ||
| T getDigit(T = ulong)(size_t n) const | ||
| if (is(T == ulong) || is(T == uint)) |
There was a problem hiding this comment.
I'd think ushort and ubyte would also be useful, but can be added later.
|
uh this is a bit late now, but shouldn't this also document what it does for negative BigInts? |
|
A note could be added but the docs say it's about the representation and the representation is the same for both negative an positive numbers. |
Get the elements of the underlying representation. This would also be useful in my
stdxdecimallibrary.