BigInt to binary

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 25 11:58:48 PDT 2015


On Saturday, 25 April 2015 at 13:13:10 UTC, Dennis Ritchie wrote:
> Hi,
> Is there a way to apply a function "format" with BigInt?
>
> -----
> import std.stdio, std.bigint, std.string;
>
> void main() {
>
> 	BigInt n = -10;
>
> 	string s = format("%b", n); // error
>
> 	writeln(s);
> }

BigInt only supports %d, %x, %X and %s:
http://dlang.org/phobos/std_bigint.html#.BigInt.toString

The missing %o and %b were probably an oversight, feel free to 
file an enhancement request or submit a PR.


More information about the Digitalmars-d-learn mailing list