diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-24 11:45:04 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-24 11:45:04 +0000 |
commit | 404bd07f934bd109901d7a9e8a903c10995ff327 (patch) | |
tree | 978d627d9c1cbea8339351256c77570e4253d850 /src/utils | |
parent | d8b5dd586db230db3f09bedba9bfc0bdb254fe57 (diff) | |
download | libcss-404bd07f934bd109901d7a9e8a903c10995ff327.tar.gz libcss-404bd07f934bd109901d7a9e8a903c10995ff327.tar.bz2 |
Fix rounding when fractional part is close to 1.
Add testcase to exercise this.
svn path=/trunk/libcss/; revision=5766
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/utils.h | 7 |
1 files changed, 4 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, |