Index: src/conversions.cc |
diff --git a/src/conversions.cc b/src/conversions.cc |
index fb09d18a407f6780283e2b8bdcc468015a747884..6048b34abf703bbe242572da228e912c1ef52f8d 100644 |
--- a/src/conversions.cc |
+++ b/src/conversions.cc |
@@ -474,12 +474,15 @@ char* DoubleToRadixCString(double value, int radix) { |
} while (fraction > delta); |
} |
- // Compute integer digits. |
+ // Compute integer digits. Fill unrepresented digits with zero. |
+ while (Double(integer / radix).Exponent() > 0) { |
+ integer /= radix; |
+ buffer[--integer_cursor] = '0'; |
+ } |
do { |
- double multiple = std::floor(integer / radix); |
- int digit = static_cast<int>(integer - multiple * radix); |
- buffer[--integer_cursor] = chars[digit]; |
- integer = multiple; |
+ double remainder = modulo(integer, radix); |
+ buffer[--integer_cursor] = chars[static_cast<int>(remainder)]; |
+ integer = (integer - remainder) / radix; |
} while (integer > 0); |
// Add sign and terminate string. |