From 73ac4cdc3f94a5d67678ba97c9192a0287db63b3 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 27 Jan 2014 16:28:07 +0100 Subject: [PATCH] truncate_string(): Be a lot laxer wrt. rounding incaccuracies Instead of 1/10000 we now add 1/128 to the width to compensate for rounding inaccuracies. Due to the limited float mantissa precision (23 bit) the previous value would already have no effect for relatively small widths (>= 128). Fixes #10455. --- src/kits/interface/InterfaceDefs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index b712b4f4b9..8c5a7e0f92 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -1422,7 +1422,7 @@ truncate_string(BString& string, uint32 mode, float width, { // add a tiny amount to the width to make floating point inaccuracy // not drop chars that would actually fit exactly - width += 0.00001; + width += 1.f / 128; switch (mode) { case B_TRUNCATE_BEGINNING: