pow exponent type issue

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 24 12:16:56 PDT 2016


I'm a little confused on why pow behaves so differently when 
switching from an int to a uint for the exponent.

import std.math : pow;
import std.stdio : writeln;

void main()
{

	float x = 2;
	int y1 = 1;
	uint y2 = 1;

	writeln(pow(x, -y1));  //prints 0.5
	writeln(pow(x, -y2));  //prints inf

}


More information about the Digitalmars-d-learn mailing list