From d2ec504fec2550f4fd046e801b34317ef4a4bab9 Mon Sep 17 00:00:00 2001 From: Martin Burggraf Date: Thu, 13 Aug 2015 21:16:40 +0200 Subject: correcting mathematical nonsense V2: Fixing the issue with numbers between 0 -1 Reviewed-by: Alan Coopersmith Signed-off-by: Alan Coopersmith --- src/xkbtext.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/xkbtext.c b/src/xkbtext.c index 013cdef..6741d1a 100644 --- a/src/xkbtext.c +++ b/src/xkbtext.c @@ -758,9 +758,17 @@ XkbGeomFPText(int val, unsigned format) } else { whole = val / XkbGeomPtsPerMM; - frac = val % XkbGeomPtsPerMM; - if (frac != 0) - snprintf(buf, bufsize, "%d.%d", whole, frac); + frac = abs(val % XkbGeomPtsPerMM); + if (frac != 0) { + if (val < 0) + { + int wholeabs; + wholeabs = abs(whole); + snprintf(buf, bufsize, "-%d.%d", wholeabs, frac); + } + else + snprintf(buf, bufsize, "%d.%d", whole, frac); + } else snprintf(buf, bufsize, "%d", whole); } -- cgit v1.2.3