summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcss/fpmath.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/libcss/fpmath.h b/include/libcss/fpmath.h
index bed5ee6..d7cac4d 100644
--- a/include/libcss/fpmath.h
+++ b/include/libcss/fpmath.h
@@ -99,10 +99,12 @@ css_float_to_fixed(const float a) {
float xx = a * (float) (1 << CSS_RADIX_POINT);
if (xx < INT_MIN)
- xx = INT_MIN;
+ return INT_MIN;
- if (xx > INT_MAX)
- xx = INT_MAX;
+ /* Conversion from int to float changes value from
+ * 2147483647 to 2147483648, so we use >= instead of >. */
+ if (xx >= (float)INT_MAX)
+ return INT_MAX;
return (css_fixed) xx;
}