diff options
author | Martin Burggraf <TSO@gmx.net> | 2015-08-13 21:16:40 +0200 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2018-03-24 11:43:51 -0700 |
commit | d2ec504fec2550f4fd046e801b34317ef4a4bab9 (patch) | |
tree | 5cdf111428b7bdff55ace925631fee735adbc766 /src/xkbtext.c | |
parent | 1c070d1153e293169909b0fc8e9ff65be9121fa0 (diff) |
correcting mathematical nonsense
V2: Fixing the issue with numbers between 0 -1
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/xkbtext.c')
-rw-r--r-- | src/xkbtext.c | 14 |
1 files 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); } |