Explorar o código

Add GetDecimalInPlace function

With the addition of the Relative Parameter Mode, the parameter mode
will no longer only be 0 or 1, but can also be 2. Added this function to
get the value.
ApisNecros hai 1 ano
pai
achega
43af95fc9c
Modificáronse 1 ficheiros con 13 adicións e 1 borrados
  1. 13 1
      IntComp/common.js

+ 13 - 1
IntComp/common.js

@@ -25,10 +25,22 @@ function DeepClone(toClone) {
  * @returns {boolean} Whether the value in that number's place is non-zero
  */
 function DecimalPlaceIsNonZero(input, place) {
-    return !!Math.floor((input / (10 ** place)) % 10);
+    return !!GetDecimalInPlace(input, place);
+}
+
+/**
+ * Get the digit in a given place of a decimal number
+ *
+ * @param {number} input The number to check
+ * @param {number} place The power of 10 to check against
+ * @returns {number} The number at the specified place in the input
+ */
+function GetDecimalInPlace(input, place) {
+    return Math.floor((input / (10 ** place)) % 10);
 }
 
 module.exports = {
     DeepClone: DeepClone,
     DecimalPlaceIsNonZero: DecimalPlaceIsNonZero,
+    GetDecimalInPlace: GetDecimalInPlace,
 };