Explicitly cast result of Math.pow to long in Armstrong (#4972)

This commit is contained in:
Piotr Idzik 2023-11-30 09:50:09 +01:00 committed by GitHub
parent f8de290188
commit fc21a8bffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ public class Armstrong {
while (originalNumber > 0) { while (originalNumber > 0) {
long digit = originalNumber % 10; long digit = originalNumber % 10;
sum += Math.pow(digit, power); // The digit raised to the power of the number of digits and added to the sum. sum += (long) Math.pow(digit, power); // The digit raised to the power of the number of digits and added to the sum.
originalNumber /= 10; originalNumber /= 10;
} }