On Sunday, 2 October 2022 at 02:02:37 UTC, rassoc wrote:
On 10/2/22 00:04, Fausto via Digitalmars-d-learn wrote:
Hello,

I am trying to use pow with an integer argument, but I cannot have a bigint result, for example, ```pow(10,72)```. Do I have to write my pow function or is there a native solution?

thanks,
Fausto


In contrast to certain scripting languages, there's no implicit promotion, you have to opt in for BigInt [1] usage in D:

```d
import std;
void main()
{
    // all print the same
    writeln(BigInt(10) ^^ 72);
    writeln(10.BigInt ^^ 72);
    writeln("10".BigInt ^^ 72);
}
```

[1] https://dlang.org/phobos/std_bigint.html#.BigInt

Thanks a lot. I am to used to C and, more important, I didn't think to look for also another operator for the power function :)


Reply via email to