Update AnyBaseToAnyBase.java

fix n="0" bug
This commit is contained in:
rabbit 2020-08-21 15:48:22 +08:00
parent 94a65964d8
commit 1e80212c23

View File

@ -115,7 +115,8 @@ public class AnyBaseToAnyBase {
// the remainder until the quotient is zero. The number in the // the remainder until the quotient is zero. The number in the
// new base is the remainders, with the last remainder // new base is the remainders, with the last remainder
// being the left-most digit. // being the left-most digit.
if (0 == decimalValue)
return "0";
// While the quotient is NOT zero: // While the quotient is NOT zero:
while (decimalValue != 0) { while (decimalValue != 0) {
// If the remainder is a digit < 10, simply add it to // If the remainder is a digit < 10, simply add it to