82e5a2f60afd1cc330ccfa0b81b8824964e976c7 |
|
21-Jul-2015 |
Hans Boehm <hboehm@google.com> |
Avoid starting long uninterruptible computations Bug: 21957088 Shorten timeouts. We usually do short computations first, so this helps to avoid starting absurdly big ones. Check size of result before converting to decimal. If the decimal conversion is likely to time out anyway, just pretent we timed out. This turns out to avoid a lot of problems, since BigInteger decimal conversion is the clear bottleneck for something like 100000! And its uninterruptible. Remove the timeout in one case in which we had previously forgotten. Check for interrupts in a couple of more places in BoundedRational. One of these caused log(10^100000) to hang for a long time. One or two trivial cleanups in code that was touched anyway. Change-Id: I3494a8ed28f681fb26634ecd90042e2f2a8008a8
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
19e93c9806c245084d81df601d5ebc38c73dd5a7 |
|
20-Jun-2015 |
Hans Boehm <hboehm@google.com> |
Reflect conversion of CR to unchecked exceptions Bug: 20667245 Update calculator code to reflect the fact that CR Errors have become exceptions, and they are now delcared local to CR. Change-Id: Ie9c9e10cef2f98a23856aa9e49328ae7ba52c9bc
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
c1ea091ae1a4d5145069bfc6248f83f5ca8f0b31 |
|
20-Jun-2015 |
Hans Boehm <hboehm@google.com> |
Improve logic for evaluation/animation interruption Bug: 21471857 Bug: 20819212 End rather than cancel() in-progress animation in the event of user interaction. Discard input that interrupted a computation only for delete, and clear, where it seems to make sense. Use similar interruption logic for physical keyboard input as for touch. Make integer exponentiation more interruptible. This remains imperfect; the latencies in a single BigInteger multiplication can be high. Filed b/21957088 to track that. Clear "instant" result before launching reevaluation. Otherwise the example from b/21957088 shows incorrect instant results for an uncomfortably long time as it's being entered. Correct some of the state maintenance operations in Calculator.java. The ANIMATE state was not being used correctly. Remove redundant cancelAll() and onCancelled() calls. Add an option to cancel without a message. Use it for clear. Change-Id: Ibab90dca0cb894e7985642f212ff41030f2fc52d
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
cd740596f6f8bdacf02f735f116ffc544f922893 |
|
14-Jun-2015 |
Hans Boehm <hboehm@google.com> |
Fix digitsRequired() for negative denominators Bug: 21789679 Also adds some tests for digitsRequired(), including one that fails without this CL. Change-Id: Ib007e753f90c019c37666d71c1cfd02301dcd360
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
50ed320c1cdd1b3624f73956a80eb2f2c2f5a01d |
|
09-Jun-2015 |
Hans Boehm <hboehm@google.com> |
Fix getShortString(), tune evaluation heuristics. Bug: 21474616 Rewrite getShortString() to also look at the least significant digit information when available, and try to mimic the display formatting code wherever appropriate. As a result, when the user hits "=", followed by "+" transitions are now more frequently smooth. Revise the evaluation heuristics so the we are more aggressive with the initial evaluation precision, and try harder to discover the leading digit in a near-zero number. Some of this is necessary to keep getShortString() happy. This version should also now guarantee that we are never worse than double precision floating pointing in displaying very small nonzero numbers. If we display a number as zero, the old calculator would have, too. (And now you can scroll to see whether it really is.) Up the BoundedRational bit limit to improve the chances of identifying exact results. In general, the incremental computation cost for operating on larger BigIntegers appears relatively low, so it makes sense to trade longer computations for fewer calls. Change-Id: I33066845b832753c109fcaf27f883b48e7e119d2
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
4db31b490443e4454d98a5ae2bc44b87149accfe |
|
31-May-2015 |
Hans Boehm <hboehm@google.com> |
Implement percent and new inverse functions Bug: 21493470 Add x^2 10^x and e^x functions, to make the recently added INV key work as expected. Implement % functionality. 10^x is essentially just macro expansions for now. % and x^2 need trivial evaluator support to provide reasonable display syntax. We decided to add evaluator support for exp() as well. Add corresponding exp() support to BoundedRational and its tests. Tiny incidental changes for problems uncovered in the process: Fix bug in tests/README.txt Evaluate the constant e only once. Add one more power test along with the exp() test. Fix proguard.flags so BRTest runs again. Change-Id: I26cfcaf6d99aeec11387297cc5586e2ddcab6add
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
c023b734310f231244f17189788ae9c17c90b9a8 |
|
29-Apr-2015 |
Hans Boehm <hboehm@google.com> |
Fix timeout, cancellation and instant display logic Bug: 20668802 Bug: 20484451 Bug: 20734909 Bug: 20738335 Change the timeout implementation to not rely on removing scheduled timeouts when an evaluation completes. This seems simper, more clearly correct and, unlike its predessessor seems to work reliably. Correctly display "cancelled" message, but only when cancelled for a reason other than timeout. Change SyntaxError to not be a Java "Error", since we routinely recover from it. Better support evaluation of partial expressions by removing trailing operators. Make some attempt to avoid redundant evaluations, since they're not as cheap as they used to be. Change the display logic to avoid frequent clearing of the display, which resulted in visible flashing. Note that the evaluation logic can now stop evaluating before the end of an expression. Substantially lengthen timeout used when computing an unrequested result. Inverse trig functions can be slow. See b/20729963. Make large factorial computations interruptable, as I mistakenly thought they were. Ignore "=" on an empty expression. I'm not positive this fixes the b/20484451, but I haven't been able to reproduce it with this patch. I have no idea whether it addresses b/20738335, but it cleans up code in that vicinity, so it would be interesting to know whether that is still reproducible. Change-Id: I67af5afc00e19a6156e1547ce4e2060c70ca367f
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
fbcef7005de4436682072927f83000b502928d25 |
|
28-Apr-2015 |
Hans Boehm <hboehm@google.com> |
Fix strings, stability bug, easy UI & correctness issues Bug: 20625562 Bug: 20649711 Bug: 20561890 Bug: 20561528 Bug: 20442590 Bug: 15473140 Bug: 20503008 Bug: 20503007 - Improve timeout text. - Recalculate when Calculator is rotated, e.g. in error state, thus reproducing message. It's unclear this is good enough, but it's better. - Fix square root parsing. - Fix concatenation of numbers when pasting by adding explicit multiplication. - Display divide by zero error differently from other domain errors. - Improved advanced keypad layout of portrait-mode tablet calculator. - Improved overflow menu order. (More to be done.) - Report zero division as zero division when we can recognize it. - Switch to floating menus for copy/paste. Change-Id: I3875414f293e62a59b0e41f0de822f29bd5ac6a6
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
9e855e82dc86b3038b3e048a56be77af114e24f4 |
|
23-Apr-2015 |
Hans Boehm <hboehm@google.com> |
Fix decimal log(), rename positive_den() Bug: 20485102 The rational version of base 10 log(0) got into an infinite loop. Change-Id: Id6263f7244c71260daa124e5eb4eea8592d0e6c7
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
013969e98ce9e3eb4f87ec6159b06a74d07b2592 |
|
14-Apr-2015 |
Hans Boehm <hboehm@google.com> |
Internationalize display again. Plus minor cleanups. Adds code for internationalization of numeric results, both in the result and formula displays. Update some now obsolete TODO comments. Change-Id: I42731bf87f5488375457f1c5c094c7f0d17b71da
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
4a6b7cb235c305761af5d7f40e74d4704e5058c8 |
|
04-Apr-2015 |
Hans Boehm <hboehm@google.com> |
Fix UI holes and bugs. Fix eval bugs. Change layout to make the result display use a fixed font size and limit the number of characters when it appears below the formula. This allows us to always get the proper expansion effect and prevents scrolling from affecting the font size. Add copy support for result display. Add paste support for the formula. Add keyboard input support. Copy/paste can be used to remember old results in the calculator. We save an identifying tag URI in the clip, in addition to text, allowing us to paste old calculator results without precision loss. Copy/paste currently does not rely on selection at all. I had trouble making it work that way in the formula. It's unclear that would be better, since we only allow copy of the entire text and paste at the end. Add a couple of alternate result display options to the overflow menu. (These appear quite useful, were trivial to implement, and give us a better excuse for the overflow menu.) Changed the behavior of the delete key in error state. Changing it to CLEAR seemed unfriendly, since it prevents corrections. This is a change from L. Made it clear that the CalculatorHitSomeButtons test is currently 95% worthless. It was apparentlly failing (due to test infrastructure issues) but throwing an exception in a thread from which it was not getting reported. Decided to keep it, since I would like a place to continue collecting regression tests, even if we can't actually run them yet. Includes some easy drive-by fixes for expression evaluation: a) 2 / 2 * 3 was mis-parsed as 2 / (2 * 3). b) Cosine evaluation had the sense of the test for a rational result reversed. c) Constants without leading digits, like .1, are now handled correctly, and decimal points in the formula are now internationalized. (That's not yet true for the result.) Change-Id: Ic24466b444b4a4633cfb036c67622c7f4fd644ec
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
75ca21c698808b61238a3aff3e0a3dfd5ba95d0e |
|
12-Mar-2015 |
Hans Boehm <hboehm@google.com> |
Add tests, fix BoundedRational bugs Add back some basic test infrastructure from the KitKat calculator, updated to make it work with the current code base and asynchronous expression evaluation. Add BoundedRational tests, designed to check that we get all the corner cases, particularly for degree-based trig functions, right. Fix a couple of BoundedRational typos that caused these tests to fail. Change-Id: I81d8f3d9bde6aa6c20f9958eabd62979babeff5b
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|
682ff5e8ad465d74b289590e5c88e0cf129ca90b |
|
09-Mar-2015 |
Hans Boehm <hboehm@google.com> |
Add BoundedRational evaluation We would like to display finite representations of calculator results when they clearly exist and are easy to identify, such as when adding currency values. We do this by computing a rational representation of the result when it exists, and using that to compute the number of digits in a finite representation. Since rational arithmetic can become very expensive, we bound the size of the results we are willing to keep. If things get too large we fall back on the standard constructive real arithmetic. Finite representations are extremely unlikely in such cases anyway. This also gives us a clear rule for when to normalize fractions, which is often a challenge with rational number packages. This also adds a couple of routines to set degree mode, but does not include the UI to actually invoke them. Thus there is still no way to test some important pieces of functionality. Change-Id: I3c1aca5aefd8d8c19bce79095bde59ee3b4127fe
/packages/apps/ExactCalculator/src/com/android/calculator2/BoundedRational.java
|