When built with MinGW, pow() may not always generate an exact integer result when supplied with integer operands. Converting the result to an integer before we use it seems to be enough to work round this issue.
This patch is for both devel and v0.9. The bug is caught by the existing VPI regression tests.
For reference, the description of the issue in the MinGW math.h header file is:
/* Excess precision when using a 64-bit mantissa for FPU math ops can
cause unexpected results with some of the MSVCRT math functions. For
example, unless the function return value is stored (truncating to
53-bit mantissa), calls to pow with both x and y as integral values
sometimes produce a non-integral result.
One workaround is to reset the FPU env to 53-bit mantissa
by a call to fesetenv (FE_PC53_ENV). Amother is to force storage
of the return value of individual math functions using wrappers.
NB, using these wrappers will disable builtin math functions and
hence disable the folding of function results at compile time when
arguments are constant. */
Log in to post a comment.