Pavan Nikhilesh <pbhagavat...@marvell.com> wrote Sunday, April 14, 2019 7:22 AM:
From: Pavan Nikhilesh <pbhagavat...@marvell.com> Fix large multiple calculation in 64 bit reciprocal division.
This "fix" has a SERIOUS bug, it needs yet another fix. I recommend to understand code first before you copy it! [...]
+ int64_t i;
uint i = 64;
+ uint64_t t; + + for (i = 1; i <= 64; i++) {
do {
+ t = x >> 63;
t = (int64_t) x >> 63; // t is either 0ULL or ~0ULL
+ x = (x << 1) | (y >> 63); + y = y << 1; + if ((x | t) >= z) { + x = x - z; + y = y + 1; + }
} while (--i > 0); Stefan Kanthak