bigint and pow
rassoc
rassoc at posteo.de
Sun Oct 2 09:22:54 UTC 2022
On 10/2/22 09:24, Fausto via Digitalmars-d-learn wrote:
> 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 :)
>
D does have pow and many other useful math functions [1], it's just not defined for BitInts. Oh, and speaking of C, you also have access to all the usual C math [1] functions with just an import:
```d
import std.stdio : writeln;
void main()
{
import std.math : pow;
writeln(pow(10, 3)); // pow from D
import core.stdc.math : pow;
writeln(pow(10, 3)); // pow from C
// can also make it more explicit to show where it is coming from:
import cmath = core.stdc.math;
writeln(cmath.pow(10, 3));
}
```
Have fun with D!
[1] https://dlang.org/library/std/math.html
[2] https://dlang.org/library/core/stdc/math.html
More information about the Digitalmars-d-learn
mailing list