Skip to content
Snippets Groups Projects
Commit 1921cb37 authored by Florian Loitsch's avatar Florian Loitsch
Browse files

Avoid negative shift.

When filling in fractional digits in a fixed representation we
might use all existing digits. When this happens, we can not look
at the next digit to see if we should round up.

Before this fix, we tried to shift by a negative amount to see if the
(non-existing) next bit was set to 1 (requiring the number to be rounded up).

Fixes #41.
parent d8d4e668
No related branches found
No related tags found
No related merge requests found
......@@ -259,7 +259,7 @@ static void FillFractionals(uint64_t fractionals, int exponent,
fractionals -= static_cast<uint64_t>(digit) << point;
}
// If the first bit after the point is set we have to round up.
if (((fractionals >> (point - 1)) & 1) == 1) {
if ((fractionals != 0) && ((fractionals >> (point - 1)) & 1) == 1) {
RoundUp(buffer, length, decimal_point);
}
} else { // We need 128 bits.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment