fcb1e611dcc6ffd98be6b6847cbeb56966b70721 |
|
13-Dec-2016 |
Hans Boehm <hboehm@google.com> |
Merge "Fix COPY string computation in exact case" into ub-calculator-euler
|
3465c782410b9e19f9a4e92cb8c74647e38a5bdc |
|
13-Dec-2016 |
Hans Boehm <hboehm@google.com> |
Fix COPY string computation in exact case Bug: 26175989 Bug: 33458621 Fix the determination of whether the currently displayed result is already exact. The old logic failed to deal with the odd corner case in which we force an initial scientific notation display because we don't have room for digit separators. When we recompute the exact result as part of a copy operation, and the exact result is an integer, do not add a trailing decimal point. Change-Id: I3f673fc428cf6982eeaf6aa1037b9f522ea2d6f9
/packages/apps/ExactCalculator/src/com/android/calculator2/UnifiedReal.java
|
e7111cfb93a073227a360f219ef3e395cb99f55d |
|
12-Dec-2016 |
Hans Boehm <hboehm@google.com> |
Add special case for exp(1) evaluation. Bug: 33539849 By returning a fixed value, we avoid redundant computation, and can recognize that e.g. e - exp(1) is exactly zero. Change-Id: Ibf8b84092ad844fa3d6b2818395c2da437fec9c8
/packages/apps/ExactCalculator/src/com/android/calculator2/UnifiedReal.java
|
4452c78e94b522c74d63056b0814a00281be296a |
|
07-Dec-2016 |
Hans Boehm <hboehm@google.com> |
Fix exponentiation and timeout issues Bug:33433764 Bug:33105915 Use the recursive algorithm for exponentiation with an integer exponent and a base that cannot be determined to be positive. Use of the log-based algorithm caused expressions like (-pi)^3 to fail. (Note that the recursive exponentiation algorithm is essentially a clone of rawPow in BoundedRational, not a new invention.) Catch stack overflows during expression evaluation and treat them as timeouts. This is a bit challenging for the underlying VM, but it's supposed to work, and it seems to. We only rely on it in cases that previously failed without anyone noticing, like 2^2^2^2^2^2. Don't just write out the long timeout information. Also read it back in. Duh. Some drive-by comment improvements. Change-Id: I13f84850de5d1b9323b63ae2b769a22d97d0ae66
/packages/apps/ExactCalculator/src/com/android/calculator2/UnifiedReal.java
|
24c91edb89b3bfecb5167d3ba4f76cf0203cb547 |
|
01-Jul-2016 |
Hans Boehm <hboehm@google.com> |
Add digit grouping to display Bug: 27461988 Add digit grouping separators to formula and result. The result display piece of this is an annoyingly complex change, since it interacts with our already subtle calculations of the number of digits to display, our initial evaluation precision, etc. We display grouping separators in the result only when the entire whole part of the number, with grouping separators, fits into the display. If it fits into the display without, but not with, grouping separators, we force scientific notation. This may require the result to be scrollable when it otherwise would not be, and leads to an interesting set of corner cases, which we claim to handle reasonably. Some cleanups were applied to make this easier, more useful, and more debuggable. These included: More accurate bookkeeping about different character widths. Otherwise scrolling with grouping separators was not smooth. Ignore grouping separators and spaces on input, as we should have been doing all along. Only redisplay the result if the character (as opposed to pixel) position changed. This makes up for some extra computation and facilitates debugging. Introduce StringUtils.java to hold digit string operations that really don't fit anywhere else. Move the duplicated repeat() function there. Change-Id: I00502b9906b184671cd3379cd68b0447939b2394
/packages/apps/ExactCalculator/src/com/android/calculator2/UnifiedReal.java
|
995e5eb3b58a5cbef2686feb34f53493c1825866 |
|
08-Feb-2016 |
Hans Boehm <hboehm@google.com> |
Refactor arithmetic code. More symbolic result tracking. Bug:21957368 Add UnifiedReal class, which represents the product of a CR and a BoundedRational. Preferring well-known constants in the CR part allows us to perform some symbolic-like symplifications, such as keeping track of rational multiples of pi. But the real motivation for this change is to factor out the combined rational/CR logic, so that we can reuse it for other applications. Our limited symbolic manipulations have several immediate effects: - Evaluator.java is cleaner. The actual arithmetic is isaolated to UnifiedReal.java, BoundedRational.java, and the external CR.java. - We can display exact symbolic representations for some irrationals. - We are guaranteed to produce correctly truncated results for those values. Switches from zeroes to 9s can no longer occur for those. - We are more likely to be able to detect division by zero up front instead of diverging. 1/(pi - pi) is detectable. - Factorial argument validity checks are more likely to be exact. - We can commonly determine the leading digit of a number near zero, and hence quickly produce appropriate scientific notation more often. - Radian trig evaluations, like sin(pi), now produce exact rational results. We also remove the separate degree-based trig function implementations, since they are no longer needed. Degrees transalate to exact multiples of pi, which are now tracked correctly. The logic for producing exact results from trig functions at special points moved from BoundedRational to UnifiedReal, and was strengthened. BoundedRational now uses a random normalization strategy, to allow MAX_SIZE to be increased sufficiently to get more benefits from some of the other changes. Break BRTest.java into UnifiedRealTest.java and BoundedRationalTest.java. The tests are still useful, but some now only apply to UnifiedReal, since the transcendental functions no longer exist in BoundedRationsl. Change-Id: Ic9d5d70252d54e17043c7328f69d93ab9225223f
/packages/apps/ExactCalculator/src/com/android/calculator2/UnifiedReal.java
|