From 6679d7c0b1a5a0b37d2426a0c275eaccffb22e60 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Thu, 29 Jul 2010 21:05:45 -0500 Subject: [PATCH] [devel] Guard instances of "floor()" with PNG_FLOATING_ARITHMETIC_SUPPORTED --- png.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/png.c b/png.c index 28537d910..cce7a0047 100644 --- a/png.c +++ b/png.c @@ -1159,7 +1159,11 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, else { /* End of loop - round the whole number. */ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED d = floor(fp + .5); +#else + d = (double)((int)(fp + .5)); +#endif if (d > 9) { @@ -1343,7 +1347,11 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, png_fixed_point png_fixed(png_structp png_ptr, double fp, png_const_charp text) { +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED double r = floor(100000 * fp + .5); +#else + double r = (double)((int)(100000 * fp + .5)); +#endif if (r <= 2147483647. && r >= -2147483648.) return (png_fixed_point)r;