https://issues.dlang.org/show_bug.cgi?id=20451
jacob <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |look.at.me.pee.please@gmail | |.com --- Comment #1 from jacob <[email protected]> --- Comparing floating point numbers with "==" is in itself an error. You shouldn't be comparing approximation of numbers to see if they are exactly the same. Anyways this works: extern(C) export void thethingy() { immutable real x = 46; immutable float xf = x; immutable double xd = x; immutable short neg2 = -2; immutable long neg8 = -8; writefln!"%.70f"(pow(xd, neg2)); writefln!"%.70f"(cast(double) (1 / (x * x))); assert(pow(xd, neg2) == cast(real) (1 / (x * x))); // cast(real) for same type. // can't just cast(double) here cause pow() returns value on the FPU // so the conversion never happens otherwise double a = pow(xd, neg2); assert(a == cast(double) (1 / (x * x))); } You are comparing different types, pow() returns real, and you were comparing it with a "double". The reason you get the same numbers when printed is because Windows doesn't actually support 80-bit floats. Their 'long double' type is just an alias for double. You guessed it writefln() under the hood uses Windows' snprintf(). https://github.com/dlang/phobos/blob/v2.089.1/std/format.d#L2660 Which is incapable of printing "real" (aka long double, 80-bit floats). --
