Package mastermind.utils
Class MathUtil
java.lang.Object
mastermind.utils.MathUtil
Provides utility methods for mathematical operations.
-
Method Summary
Modifier and TypeMethodDescriptiondigitsFromBase
(int number, int base, int arrLength) Extracts the digits of a given number in a specified base and returns them in a list, padded with leading zeros to ensure the resulting list has the specified length.
-
Method Details
-
digitsFromBase
Extracts the digits of a given number in a specified base and returns them in a list, padded with leading zeros to ensure the resulting list has the specified length.- Parameters:
number
- The input number to be converted into digits of the specified base.base
- The base in which the number's digits are extracted.arrLength
- The desired length of the resulting list. If the extracted digits are fewer than this length, the list is padded with leading zeros.- Returns:
- An ArrayList containing the digits of the number in the specified base, ordered from the most significant digit to the least significant digit.
-