Re: [PATCH v3 1/4] lib/string_helpers: change blk_size to u32 for string_get_size() interface

From: James Bottomley
Date: Tue Nov 03 2015 - 16:19:38 EST


On Tue, 2015-11-03 at 21:57 +0100, Rasmus Villemoes wrote:
> On Tue, Nov 03 2015, James Bottomley <jbottomley@xxxxxxxx> wrote:
>
> >
> > It was a suggestion when I explained what the missing sources of
> > precision were, I don't think it's really a suggestion when it comes
> > with an exemplary patch.
>
> exÂemÂplaÂry
> adjective
>
> 1.
> serving as a desirable model; representing the best of its kind.
>
> Said exemplary patch produces "1.10 KiB" for size=2047,
> blk_size=1. (This is caused by the introduction of rounding, and is
> probably fixable.)
>
> James, I do understand the algorithm you're trying to use. What I don't
> understand is why you insist on using the approach of reducing size and
> blk_size all the way before multiplying them. It seems much simpler to
> just reduce them till they're below U32_MAX (not keeping track of any
> remainders at that point), multiply them, and then proceed as usual,
> This avoids having to deal with weird cross-multiplication terms, gives
> more accurate results (yes, I tested that) and avoids the extra 64/32
> division you introduce by decrementing i.

Well, wood and trees, I think. I don't believe there's any more
accuracy with the second order term, but it is a lot simpler for anyone
to understand. I'll post a v2.

James

N‹§²æ¸›yú²X¬¶ÇvØ–)Þ{.nlj·¥Š{±‘êX§¶›¡Ü}©ž²ÆzÚj:+v‰¨¾«‘êZ+€Êzf£¢·hšˆ§~†­†Ûÿû®w¥¢¸?™¨è&¢)ßf”ùy§m…á«a¶Úÿ 0¶ìå