BigInt.toString

Salih Dincer salihdb at hotmail.com
Thu Aug 4 01:32:15 UTC 2022


On Thursday, 4 August 2022 at 00:45:44 UTC, Ruby The Roobster 
wrote:
> How exactly can one store the string representation of a 
> BigInt?  The seemingly obvious:
> dchar[] is necessary for my project.
> Assume that val is a BigInt with
> a value set earlier:
> ```d
> val.toString(ret, "%d");
> ```
> doesn't work.

I guess I wrote the following anything like that you want.

```d
void main()
{
   import std.bigint,
          std.string : representation;

   BigInt i = 1001;
   auto val = i.to!(dchar[]);
   assert(val.representation == [49, 48, 48, 49]);
}
```

Is that what you want?

SDB at 79


More information about the Digitalmars-d-learn mailing list