Loading src/com/android/calculator2/BoundedRational.java +4 −1 Original line number Diff line number Diff line Loading @@ -485,6 +485,7 @@ public class BoundedRational { } private static final BigInteger BIG_FIVE = BigInteger.valueOf(5); private static final BigInteger BIG_MINUS_ONE = BigInteger.valueOf(-1); // Return the number of decimal digits to the right of the // decimal point required to represent the argument exactly, Loading Loading @@ -514,7 +515,9 @@ public class BoundedRational { // (Recall the fraction was in lowest terms to start with.) // Otherwise the powers of 10 we need to cancel the denominator // is the larger of powers_of_two and powers_of_five. if (!den.equals(BigInteger.ONE)) return Integer.MAX_VALUE; if (!den.equals(BigInteger.ONE) && !den.equals(BIG_MINUS_ONE)) { return Integer.MAX_VALUE; } return Math.max(powers_of_two, powers_of_five); } } tests/src/com/android/calculator2/BRTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,12 @@ public class BRTest extends TestCase { check(BR_0.signum() == 0, "signum(0)"); check(BR_M1.signum() == -1, "signum(-1)"); check(BR_2.signum() == 1, "signum(2)"); check(BoundedRational.digitsRequired(BoundedRational.ZERO) == 0, "digitsRequired(0)"); check(BoundedRational.digitsRequired(BoundedRational.HALF) == 1, "digitsRequired(1/2)"); check(BoundedRational.digitsRequired(BoundedRational.MINUS_HALF) == 1, "digitsRequired(-1/2)"); check(BoundedRational.digitsRequired(new BoundedRational(1,-2)) == 1, "digitsRequired(1/-2)"); // We check values that include all interesting degree values. BoundedRational r = BR_M390; while (!r.equals(BR_390)) { Loading Loading
src/com/android/calculator2/BoundedRational.java +4 −1 Original line number Diff line number Diff line Loading @@ -485,6 +485,7 @@ public class BoundedRational { } private static final BigInteger BIG_FIVE = BigInteger.valueOf(5); private static final BigInteger BIG_MINUS_ONE = BigInteger.valueOf(-1); // Return the number of decimal digits to the right of the // decimal point required to represent the argument exactly, Loading Loading @@ -514,7 +515,9 @@ public class BoundedRational { // (Recall the fraction was in lowest terms to start with.) // Otherwise the powers of 10 we need to cancel the denominator // is the larger of powers_of_two and powers_of_five. if (!den.equals(BigInteger.ONE)) return Integer.MAX_VALUE; if (!den.equals(BigInteger.ONE) && !den.equals(BIG_MINUS_ONE)) { return Integer.MAX_VALUE; } return Math.max(powers_of_two, powers_of_five); } }
tests/src/com/android/calculator2/BRTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,12 @@ public class BRTest extends TestCase { check(BR_0.signum() == 0, "signum(0)"); check(BR_M1.signum() == -1, "signum(-1)"); check(BR_2.signum() == 1, "signum(2)"); check(BoundedRational.digitsRequired(BoundedRational.ZERO) == 0, "digitsRequired(0)"); check(BoundedRational.digitsRequired(BoundedRational.HALF) == 1, "digitsRequired(1/2)"); check(BoundedRational.digitsRequired(BoundedRational.MINUS_HALF) == 1, "digitsRequired(-1/2)"); check(BoundedRational.digitsRequired(new BoundedRational(1,-2)) == 1, "digitsRequired(1/-2)"); // We check values that include all interesting degree values. BoundedRational r = BR_M390; while (!r.equals(BR_390)) { Loading