[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <op.vg7owkd67p4s8u@pikus>
Date: Tue, 10 Aug 2010 09:39:46 +0200
From: Michał Nazarewicz <m.nazarewicz@...sung.com>
To: Michal Nazarewicz <mina86@...a86.com>,
Denys Vlasenko <vda.linux@...glemail.com>
Cc: linux-kernel@...r.kernel.org,
"Douglas W. Jones" <jones@...uiowa.edu>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCHv2 1/3] lib: vsprintf: optimised put_dec_trunc() and
put_dec_full()
> On Sunday 08 August 2010 21:29, Michal Nazarewicz wrote:
>> + /*
>> + * '(x * 0xcccd) >> 19' is an approximation of 'x / 10' that
>> + * gives correct results for all x < 81920. However, because
>> + * intermediate result can be at most 32-bit we limit x to be
>> + * 16-bit.
>> + *
>> + * Because of those, we check if we are dealing with a "big"
>> + * number and if so, we make it smaller remembering to add to
>> + * the most significant digit.
>> + */
>> + if (q >= 50000) {
>> + a = '5';
>> + q -= 50000;
> ...
>> + /*
>> + * We need to check if q is < 65536 so we might as well check
On Tue, 10 Aug 2010 05:17:48 +0200, Denys Vlasenko <vda.linux@...glemail.com> wrote:
> You meant "need to check if q is < 81920"?
No. 81920 is a 17 bit number and when we multiply it by 0xcccd we lose
the most significant bit. Therefore we cannot use the '(x * 0xcccd) >>
19' approximation for numbers which are higher then 65535.
>> + * if we can just call the _full version of this function.
>> + */
>> + if (q > 9999)
>> + return put_dec_full(buf, q);
--
Best regards, _ _
| Humble Liege of Serenely Enlightened Majesty of o' \,=./ `o
| Computer Science, Michał "mina86" Nazarewicz (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists