From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754523AbbJ0IpZ (ORCPT ); Tue, 27 Oct 2015 04:45:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38403 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753836AbbJ0IpU (ORCPT ); Tue, 27 Oct 2015 04:45:20 -0400 From: Vitaly Kuznetsov To: Rasmus Villemoes Cc: Andrew Morton , Andy Shevchenko , Ulf Hansson , James Bottomley , Kees Cook , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] lib/string_helpers.c: don't lose precision in string_get_size() References: <1445867720-25473-1-git-send-email-vkuznets@redhat.com> <1445867720-25473-3-git-send-email-vkuznets@redhat.com> <8737wx712w.fsf@rasmusvillemoes.dk> Date: Tue, 27 Oct 2015 09:45:16 +0100 In-Reply-To: <8737wx712w.fsf@rasmusvillemoes.dk> (Rasmus Villemoes's message of "Mon, 26 Oct 2015 22:48:55 +0100") Message-ID: <87bnbkya1v.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rasmus Villemoes writes: > So I also played with this over the weekend, and also threw together a > stupid script to check the output. I see you have more or less the same > idea I used, namely to combine size and blk_size earlier. > > I put some code on github, https://github.com/Villemoes/get_size. All > versions still fail a very simply case, size=1594323, blk_size=1, for > which the correct answer is "1.52 MiB", but we get "1.51 MiB". Yes, the algorithm still has minor glitches (e.g. rounding issues) but I'd say keeping it simple enough here is worth it. > But both > your version and my two attempts seem to have the property that they are > always at most one ULP (unit in the last place) too low, and never too > high. ATM, my version 2 fails 70 of the 13598 test cases, while yours > fail 86 (the former being a strict subset of the latter), so they're > very similar. > > Regardless of which algorithm we go with, I have some cleanups I'd like > to do, but they're mostly independent and can wait. > > Rasmus -- Vitaly