From bf5632c30654b3560633b58019d13b37260ca137 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 1 Aug 2014 19:38:29 +0000 Subject: 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. --- term.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'term.c') diff --git a/term.c b/term.c index 3a8fddda..4d50856a 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.225 2014/08/01 19:25:52 schwarze Exp $ */ +/* $Id: term.c,v 1.226 2014/08/01 19:38:29 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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)); } -- cgit v1.2.3