diff --git a/src/main/java/com/sheepit/client/Utils.java b/src/main/java/com/sheepit/client/Utils.java index 416e2fc..da96803 100644 --- a/src/main/java/com/sheepit/client/Utils.java +++ b/src/main/java/com/sheepit/client/Utils.java @@ -255,23 +255,16 @@ public class Utils { } final Matcher m = Pattern.compile("([\\d.,]+)\\s*(\\w)").matcher(in); m.find(); - int scale = 1; - switch (m.group(2).charAt(0)) { + long scale = 1; + switch (Character.toUpperCase(m.group(2).charAt(0))) { case 'T': - case 't': - scale = 1000 * 1000 * 1000 * 1000; - break; - case 'G': - case 'g': - scale = 1000 * 1000 * 1000; - break; + scale *= 1000; //Multiply by 1000 each time the higher the metric prefix + case 'G': //Note the lack of break statements, thus it executes through + scale *= 1000; case 'M': - case 'm': - scale = 1000 * 1000; - break; + scale *= 1000; case 'K': - case 'k': - scale = 1000; + scale *= 1000; break; } return Math.round(Double.parseDouble(m.group(1)) * scale);