diff --git a/magick/image-private.h b/magick/image-private.h index 07b083fe6..b371af9dd 100644 --- a/magick/image-private.h +++ b/magick/image-private.h @@ -78,14 +78,13 @@ static inline ssize_t CastDoubleToLong(const double x) { errno=ERANGE; return((ssize_t) MAGICK_SSIZE_MAX); - } - value=ceil(x); + } value=ceil(x); if (value < ((double) MAGICK_SSIZE_MIN+1)) { errno=ERANGE; return((ssize_t) MAGICK_SSIZE_MIN); } - return((ssize_t) x); + return((ssize_t) value); } static inline QuantumAny CastDoubleToQuantumAny(const double x) @@ -124,13 +123,12 @@ static inline size_t CastDoubleToUnsigned(const double x) errno=ERANGE; return((size_t) MAGICK_SIZE_MAX); } - value=ceil(x); - if (ceil(x) < 0.0) + if (value < 0.0) { errno=ERANGE; return(0); } - return((size_t) x); + return((size_t) value); } static inline double DegreesToRadians(const double degrees)