Skip to content

Commit

Permalink
Merge pull request #5913 from Biotronic/Issue18048
Browse files Browse the repository at this point in the history
Fixed 18048 std.bigint.toDecimalString is impure
merged-on-behalf-of: Jack Stouffer <jack@jackstouffer.com>
  • Loading branch information
dlang-bot committed Dec 10, 2017
2 parents 975ab3d + 0dac210 commit f01efe3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions std/bigint.d
Expand Up @@ -1082,16 +1082,16 @@ Returns:
A $(D string) that represents the $(D BigInt) as a decimal number.
*/
string toDecimalString(const(BigInt) x)
string toDecimalString(const(BigInt) x) pure nothrow
{
string outbuff="";
void sink(const(char)[] s) { outbuff ~= s; }
x.toString(&sink, "%d");
return outbuff;
auto buff = x.data.toDecimalString(x.isNegative ? 1 : 0);
if (x.isNegative)
buff[0] = '-';
return buff;
}

///
@system unittest
@system pure unittest
{
auto x = BigInt("123");
x *= 1000;
Expand Down

0 comments on commit f01efe3

Please sign in to comment.