Why pow() won't go beyond 2^31?

Alex sascha.orlov at gmail.com
Thu Nov 29 07:58:46 UTC 2018


On Thursday, 29 November 2018 at 07:07:06 UTC, Murilo wrote:
> I am using the function pow() from std.math but if I try pow(2, 
> 32) it returns 0, it doesn't compute beyond the maximum value 
> of an int(2^31) and I am working with long. What should I do?

what exactly is your input?

´´´
import std.stdio;
import std.experimental.all;

void main()
{
	long u = 2;
	assert(pow(u,32) == 4294967296);
	assert(pow(2UL,32) == 4294967296);
}
´´´


More information about the Digitalmars-d-learn mailing list