newlib-nano-1.0 icon indicating copy to clipboard operation
newlib-nano-1.0 copied to clipboard

wrong implementation of __mulhi3

Open amaneureka opened this issue 6 years ago • 0 comments

This is current implementation in code base: image

if a is an even integer or any integer with 0s at lower significant followed by 1s. then it will end up in an infinite loop.

Correct code should be

while(a)
{
    if (a & 1) r += b;
    b <<= 1;
    a >>= 1;
}

amaneureka avatar Nov 29 '18 05:11 amaneureka