On 10 June 2017 at 23:13, Linus Torvalds <[email protected]> wrote: > On Sat, Jun 10, 2017 at 12:49 PM, Lubomir I. Ivanov <[email protected]> > wrote: >> >> perhaps both the lrint() calls should be removed and let QString() >> with 'f' (0/1) handle that? > > Agfreed. The whole "lbs = lrint(lbs + 0.05);" thing isn't even a > sensible thing to do in the first place, and the other version (that > adds half a lbs) is confused too, since lrint() already rounds. > > So ack on your patch. >
attached is the signed-off patch with a commit message. maybe Dirk can confirm if we need to handle it differently. lubomir --
From d8211d12e32362fb3b983a8f256831f6406a35e8 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" <[email protected]> Date: Sat, 10 Jun 2017 23:21:08 +0300 Subject: [PATCH] qthelper.cpp: leave lbs rounding to QString().arg() with 'f' The following call in weight_string(): str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1); will make values in lbs larger or equal to 40 to have no fractional part and be rounded to nearest, while values less than 40 will have one decimal place. fixes #412 Signed-off-by: Lubomir I. Ivanov <[email protected]> --- core/qthelper.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 811f653..2a897e8 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -51,10 +51,6 @@ QString weight_string(int weight_in_grams) str = QString("%1.%2").arg(kg).arg((unsigned)(gr + 50) / 100); } else { double lbs = grams_to_lbs(weight_in_grams); - if (lbs >= 40.0) - lbs = lrint(lbs + 0.5); - else - lbs = lrint(lbs + 0.05); str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1); } return (str); -- 1.7.11.msysgit.0
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
