summaryrefslogtreecommitdiff
path: root/src/css.hh
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-08-23 22:53:11 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-08-23 22:53:11 +0200
commitd4d54185af6c2217316cab75dae5de26a34d7ae2 (patch)
treebd2fa163c1fa35c1c8b1272de7702c29147101d1 /src/css.hh
parent58f69677409b016d615143d02868ac7a18496779 (diff)
add lout::misc::roundInt() for double -> int conversion
Add lout::misc::roundInt() and use it for double -> int conversion instead of doing the + 0.5 trick all over the place. It was wrong for negative values and we might even replace roundInt() with rint() from libm in the future. Reported-by: corvid
Diffstat (limited to 'src/css.hh')
-rw-r--r--src/css.hh2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/css.hh b/src/css.hh
index b23eb9a3..2e9dd2b5 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -90,7 +90,7 @@ inline CssLength CSS_CREATE_LENGTH (float v, CssLengthType t) {
switch (t) {
case CSS_LENGTH_TYPE_PX:
- iv = (int) (v + 0.5);
+ iv = lout::misc::roundInt(v);
if (iv > CSS_LENGTH_INT_MAX)
iv = CSS_LENGTH_INT_MAX;
else if (iv < -CSS_LENGTH_INT_MAX)