summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/utils/utils.h7
-rw-r--r--test/data/number/number.dat6
2 files changed, 10 insertions, 3 deletions
diff --git a/src/utils/utils.h b/src/utils/utils.h
index f1ab6d7..333a33f 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -106,9 +106,10 @@ static inline fixed number_from_css_string(const css_string *string,
len--;
}
fracpart = ((1 << 10) * fracpart + pwr/2) / pwr;
- /* Extra paranoid clamp to maximum fractional part */
- if (fracpart >= (1 << 10))
- fracpart = (1 << 10) - 1;
+ if (fracpart >= (1 << 10)) {
+ intpart++;
+ fracpart &= (1 << 10) - 1;
+ }
}
/* If the intpart is larger than we can represent,
diff --git a/test/data/number/number.dat b/test/data/number/number.dat
index a8c9cae..48ecc20 100644
--- a/test/data/number/number.dat
+++ b/test/data/number/number.dat
@@ -132,3 +132,9 @@ x
0.124
#reset
+#data
+0.999512
+#expected
+1.000
+#reset
+