diff options
author | James Bottomley <JBottomley@Odin.com> | 2016-01-20 14:58:29 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-25 12:01:21 -0800 |
commit | 726ecfc321994ec6ab044c1e3e5886408de991ac (patch) | |
tree | 9971983144bbc9f28d8c1e3e2a8cbccc2afeefc4 /drivers/isdn/hardware/eicon/os_bri.c | |
parent | 5c73252f746d4973294b7ae7eead944f4a5210f8 (diff) |
string_helpers: fix precision loss for some inputs
commit 564b026fbd0d28e9f70fb3831293d2922bb7855b upstream.
It was noticed that we lose precision in the final calculation for some
inputs. The most egregious example is size=3000 blk_size=1900 in units
of 10 should yield 5.70 MB but in fact yields 3.00 MB (oops).
This is because the current algorithm doesn't correctly account for
all the remainders in the logarithms. Fix this by doing a correct
calculation in the remainders based on napier's algorithm.
Additionally, now we have the correct result, we have to account for
arithmetic rounding because we're printing 3 digits of precision. This
means that if the fourth digit is five or greater, we have to round up,
so add a section to ensure correct rounding. Finally account for all
possible inputs correctly, including zero for block size.
Fixes: b9f28d863594c429e1df35a0474d2663ca28b307
Signed-off-by: James Bottomley <JBottomley@Odin.com>
Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/isdn/hardware/eicon/os_bri.c')
0 files changed, 0 insertions, 0 deletions