aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-10-24 02:39:52 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-10-24 02:39:52 +1000
commite76f9156bea6c2f17d7e2a06744f475de7252da9 (patch)
tree39b21e7bf9ef8545155713f34aee8b1206417cd8 /src/Java/gtPlusPlus/core/util
parent4c30de81baeb39872215a5af47feab8378e9b627 (diff)
downloadGT5-Unofficial-e76f9156bea6c2f17d7e2a06744f475de7252da9.tar.gz
GT5-Unofficial-e76f9156bea6c2f17d7e2a06744f475de7252da9.tar.bz2
GT5-Unofficial-e76f9156bea6c2f17d7e2a06744f475de7252da9.zip
+ Finally finished the Chemical Compound Tooltips. Still needs formatting improvements, but the figures and compound should be correct.
☼ Broke Mixer recipes.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r--src/Java/gtPlusPlus/core/util/math/MathUtils.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
index b4aec5a8bf..8fab1341d3 100644
--- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java
+++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
@@ -222,5 +222,37 @@ public class MathUtils {
Utils.LOG_WARNING("It will decode into "+Integer.decode(temp)+".");
return Integer.decode(temp);
}
+
+ public static long[] simplifyNumbersToSmallestForm(long[] inputArray){
+ long GCD = gcd(inputArray);
+ long[] outputArray = new long[inputArray.length];
+ for (int i=0;i<inputArray.length;i++){
+ if (GCD != 0)
+ outputArray[i] = (inputArray[i]/GCD);
+ else
+ outputArray[i] = inputArray[i];
+ }
+ if (outputArray.length > 0)
+ return outputArray;
+ return null;
+ }
+
+ private static long gcd(long a, long b){
+ while (b > 0)
+ {
+ long temp = b;
+ b = a % b; // % is remainder
+ a = temp;
+ }
+ return a;
+ }
+
+ private static long gcd(long[] input){
+ long result = input[0];
+ for(int i = 1; i < input.length; i++) result = gcd(result, input[i]);
+ return result;
+ }
+
+
}