BigInt.toString

Ruby The Roobster rubytheroobster at yandex.com
Thu Aug 4 01:37:04 UTC 2022


On Thursday, 4 August 2022 at 01:05:31 UTC, H. S. Teoh wrote:
>
> Don't call .toString directly. Instead, use std.format.format:
>
> ```d
> import std;
> void main() {
> 	auto x = BigInt("123123123123123123123123123123123123");
> 	string s = format("%s", x); // this gives you the string 
> representation
> 	writeln(s); // prints "123123123123123123123123123123123123"
>
> 	// If you need to convert to dchar[]:
> 	dstring ds = s.to!(dchar[]);
>
> 	// Or if you want a direct formatting into dchar[] without 
> going
> 	// through a string intermediate:
> 	auto app = appender!(dchar[]);
> 	app.formattedWrite("%s", x");
> 	dchar[] dcharArray = app.data; // now you have your dchar[]
> }
> ```
>
> Hope this is clear.
>
>
> T

Thank you.  This worked.


More information about the Digitalmars-d-learn mailing list