diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-01 19:38:29 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-01 19:38:29 +0000 |
commit | 41b01a2448e5d5de474613c0bf5aff6cfcb30316 (patch) | |
tree | 3a91d91e1f4f94e0b9068f8f1b399f8b1fb433c9 | |
parent | a4156c97a7eaea0360abdbc488f740cc4ad6f79f (diff) | |
download | mandoc-41b01a2448e5d5de474613c0bf5aff6cfcb30316.tar.gz |
Fix floating point handling: When converting double to size_t,
properly round to the nearest M (=0.001m), which is the smallest
available unit.
This avoids weirdness like (size_t)(0.6 * 10.0) == 5
by instead calculating (size_t)(0.6 * 10.0 + 0.0005) == 6,
and so it fixes the indentation of the readline(3) manual.
-rw-r--r-- | term.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -793,7 +793,7 @@ term_vspan(const struct termp *p, const struct roffsu *su) if (r < 0.0) r = 0.0; - return((size_t)r); + return((size_t)(r + 0.0005)); } size_t @@ -804,5 +804,5 @@ term_hspan(const struct termp *p, const struct roffsu *su) v = (*p->hspan)(p, su); if (v < 0.0) v = 0.0; - return((size_t)v); + return((size_t)(v + 0.0005)); } |