From 404bd07f934bd109901d7a9e8a903c10995ff327 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 24 Nov 2008 11:45:04 +0000 Subject: Fix rounding when fractional part is close to 1. Add testcase to exercise this. svn path=/trunk/libcss/; revision=5766 --- src/utils/utils.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/utils/utils.h') 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, -- cgit v1.2.3