diff --git a/png.c b/png.c index aacba1a61d..84f166e434 100644 --- a/png.c +++ b/png.c @@ -2699,7 +2699,7 @@ png_fixed(const png_struct *png_ptr, double fp, const char *text) { double r = floor(100000 * fp + .5); - if (r > 2147483647. || r < -2147483648.) + if (!(r >= -2147483648. && r <= 2147483647.)) png_fixed_error(png_ptr, text); # ifndef PNG_ERROR_TEXT_SUPPORTED @@ -2718,7 +2718,7 @@ png_fixed_ITU(const png_struct *png_ptr, double fp, const char *text) { double r = floor(10000 * fp + .5); - if (r > 2147483647. || r < 0) + if (!(r >= 0. && r <= 2147483647.)) png_fixed_error(png_ptr, text); # ifndef PNG_ERROR_TEXT_SUPPORTED diff --git a/pngrtran.c b/pngrtran.c index 25a333fe8a..39ee1943e7 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -304,7 +304,7 @@ convert_gamma_value(png_struct *png_ptr, double output_gamma) /* This preserves -1 and -2 exactly: */ output_gamma = floor(output_gamma + .5); - if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN) + if (!(output_gamma >= PNG_FP_MIN && output_gamma <= PNG_FP_MAX)) png_fixed_error(png_ptr, "gamma value"); return (png_fixed_point)output_gamma;