ryu
ryu copied to clipboard
More efficient removing of trailing zeros
trafficstars
Please, consider replacing of this loop by the following code:
while (vm % 10 == 0) {
vm /= 10;
vr = vm;
lastRemovedDigit = 0;
++removed;
}
Also, I think that the same kind of loop can be optimized for 64-bit values too.
The logic behind this simplification is that after passing of vp / 10 > vm / 10 and vm % 10 == 0 checks it is guarantied that vr - vm < 5.