History log of /packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9192d5c751f2aaf1d18bb9b2f715905ffd9d5925 23-Sep-2015 Hans Boehm <hboehm@google.com> Cleanup of timeout handling and message

Bug: 21470513

Prevent timeout message from disappearing on rotation.
Have long timeout setting survive rotation. Following Justin's
suggestion, associate it with a given expression and reset when
expression is cleared.

This does mean that when you rotate a device displaying an expensive-
-to-compute result, the device will initially display the formula for
several seconds, before it redisplays the result. Previously you
had to reenable the long timeout. Neither is 100% ideal.

Change-Id: Ibf8e151dd37ebadf1e86adee4718e8fa8f66b975
(cherry picked from commit 5e6a0ca2fcccb9ed16a465cf2a7e30ee5f7e0e67)
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
3d4a67d1ed392dd4788b84259d3d7ed7d694edf7 06-Aug-2015 Hans Boehm <hboehm@google.com> Address FIXME comments from previous cleanup CL

Bug: 24811759
Bug: 22047258

Add code to actively prevent ...99999 from getting turned back into
...00000 . This may have been imposssible anyway, but I couldn't
prove it.

Add tests for some Evaluator static functions, including the new
unflipZeroes().

Fix a minor bug in exponentEnd() discovered in the process.
The logic for limiting exponent length was wrong.

Remove some no longer needed code to force a reevaluation.

Generalize getPadding() function to repeat() and make it static.
Remove leadingZeroes() which is no longer used.

Make getMsdIndex() return the correct result even if it has changed
due to reevaluation.

Change-Id: Id457d8327ce0bc184d72ef78ddd3dbdaab7c6c78
(cherry picked from commit 7a432880b9d42b91a7069c6fb5398470f3cff19e)
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
b13daf1050757fe3c69c2f0246de33e7e69b5fa9 28-Jul-2015 Hans Boehm <hboehm@google.com> Evaluator.java and CalculatorExpr.java cleanup

Bug: 24811759
Bug: 21960281
Bug: 22047258

No substantive changes.

Reformat to 100 columns.

Correct and/or remove obsolete comments and occasional bits of clearly
dead code.

Better follow coding conventions.

Rename variables for both internal consistency and consistency with
other files. This included a few renamings in Calculator.java
and CalculatorResult.java, and a comment fix in CalculatorResult.java.

Rename public fields per coding convention. Correctly declare more
nested classes static.

Document FIXME issues to be addressed in followup CL. This includes
a careful look at the msd computations. I cannot construct any
failing examples, but I also cannot currently construct a correctness
argument.

Change-Id: I5c67493eeb7730edb4b3ca3ba1cb8b7d2b87dbc2
(cherry picked from commit abe2862bc936dd083b5ba19b68c68ea4cc44b2f6)
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
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/Evaluator.java
ae807e1d4d5764d74fcbc44556945ff345c27157 15-Jul-2015 Hans Boehm <hboehm@google.com> Force reevaluation if mChangedValue is true

Bug: 22481292

This could result in display of an old result.

Factor out code to start a result evaluation.

Change-Id: I651d4386323c0abd7a86176b386072093345a1b1
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
0b9806f624f25e7e0302da4cf55eda21f8c28163 30-Jun-2015 Hans Boehm <hboehm@google.com> Support pasting of scientific notation numbers

Bug: 21470972

Support pasting of numbers using scientific notation with 'E'. This
is intentionally very restricted to dodge ambiguities with the
constant e. We only accept a scientific notation constant if it is

1) Contained within a single pasted text element.
2) Uses capital 'E' to introduce the exponent.
3) Does not contain an explicit '+' in the exponent.

We do currently use the same notion of 'digit' as elsewhere, i.e.
Character.isDigit(), which might be too general.

For consistency, and to make sure that we can recognize machine
generated output, this also adds a few more aliases for text input
of arithmetic operators.

For consistency, always use 'E' internally for scientific notation as
well.

We ensure that a pasted numeric string is not concatenated with
a pre-existing constant. This is a judgment call, but it means
that pasting a previous calculator result gets similar treatment
whether or not we are still running the same calculator instance.

We support limited editing on exponents. Once an exponent is deleted,
the only way to restore it is via pasting. The 10^x button
produces similar results, though with different operator precedence
behavior.

Change-Id: I2d0f3dceb641cdad327fd3c3540b5eea38030146
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
e8553769f4b06650da0ca22a1bf741d0aad96e74 27-Jun-2015 Hans Boehm <hboehm@google.com> Make trailing operator handling consistent with L

Bug: 246391

Only ignore trailing BINARY operators when computing instant results.
We used to be much more aggressive.

Also ignore trailing binary operators when the user hits "=".

This makes us consistent with the L design and ensures that instant
results don't turn into errors when the user hits "=".

Change-Id: I260e95d152168b70774330ac95d5bc567cf79b3d
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.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/Evaluator.java
79ffb5221096d5825073a0caa47fbe646520acad 25-Jun-2015 Hans Boehm <hboehm@google.com> Merge "Improve logic for evaluation/animation interruption" into mnc-dev
15a853dd8410b2b690c3907860b6631c2d814928 24-Jun-2015 Hans Boehm <hboehm@google.com> Restore original scroll position on =

Bug: 22041219

Restore default scrolling position when hitting enter after scrolling
an instant display result.

We could instead preserve the position and fix the display logic to
no longer get confused by a non-default initial position. But this
feels more natural to me.

Change-Id: I43bb936b5bb1b5af7a7befb90fdfc0f745fb7729
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.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/Evaluator.java
8b1efdb8631462d50512ec8024d11ea53ee7fcfe 23-Jun-2015 Justin Klaassen <justinklaassen@google.com> Persist radian/degree mode

Bug: 21756459
Change-Id: Id8889c8a1f7cda255de2eeebedfbdc1fad7634b1
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
187d3e93b13bf0d8711ad5ecaab2deb9909b5f23 10-Jun-2015 Hans Boehm <hboehm@google.com> Improve logic for when to display instant result

Bug: 21497671

Fix mChangedValue handling, so that it is only reset after an actual
evaluation, and is set when an expression is "collapsed".

Consistently produce instant results for solitary pre-evaluated
expressions if and only if they involve an abbreviation.

Change-Id: I4e1f824e2353cbe78b1827f3930c72666832cff4
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.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/Evaluator.java
e4a959ec862ff83a1ceb5904225fbe2d4248a9b8 09-Jun-2015 Hans Boehm <hboehm@google.com> Merge "Consistently avoid displaying trailing zeroes" into mnc-dev
a0e45f306463394d9eeeb887b42ae18c72d69136 30-May-2015 Hans Boehm <hboehm@google.com> Consistently avoid displaying trailing zeroes

Bug: 21405924
Bug: 21529236
Bug: 21534231

This limits the display of trailing zeroes to the case in which
they avoid the need for scientic notation, and to the case of
results we did not identify as rational. This means that you
can use scrolling as an indicator of whether there may be more
digits.

The old code exhibited some misbehavior around this, the most
serious of which was probably the second bug listed above.

This now uses scientific notation more aggressively for small
numbers (b/21534231).

This patch unfortunately needs to deal with many odd corner cases
to make sure that we stop scrolling at just the right point, before
the first trailing zero appears, even if there are exponents
involved. I tested as many corner cases as I could think of.
And the testing exposed other preexisting bugs.
I do not know of a good way to avoid this without reverting
to the old scroll-through-trailing-zeroes behavior.

This significantly changes the behavior on e.g.

10^30 (Previously allowed scrolling to the decimal point, now is
unscrollable.)
10^-20 (Weird initial display with trailing zeroes; which could not
be reproduced after scrolling.)

It turns out that formatResult() scientific notation formatting
could accidentally extend the input result by 1 or 2 characters.
Based on my testing, the one character case was actually a feature:
Since there was a decimal point in the result the extra ellipsis
space seems to always give us plenty of room. The two character
case whoever sometimes resulted in wrapping, and is fixed here.
The one character case is now official. Ideally we should check
that we actually have enough space; currently I just assume a
single additional character.

Disallow scrolling left of the default position. This seems
more consistent with TextView scrolling and eliminates some
crufty code.

Fixed an off-by-one error in getPreferredPrec, which resulted in
positive results that were one character too short.

Change-Id: I13657377d098055def99e7a173f71f40d361fe3c
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
cc1e8e2833d1700ff50fac78f1e3895763223bc0 05-Jun-2015 Justin Klaassen <justinklaassen@google.com> Update strings per UX review

Bug: 20497138
Bug: 20648856
Change-Id: Id71e2c1922447957b61e3c06b205f991f01eea27
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.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/Evaluator.java
4459516a2c116ddf80725d6a96a69186ccddc329 29-May-2015 Justin Klaassen <justinklaassen@google.com> Polish display and evaluate animation

Bug: 20915670
Bug: 21489377

- Adjust font metrics across all supported device configurations to
support font scaling and min touch size requirements.
- Support proper font scaling for non-scrollable results when performing
the evaluate animation.
- Remove restriction for only using 4/5 of the width of the result
display (NOTE: the result's textSize must match the formula's
minTextSize).
- Add AlignedTextView base class to ensure formula/result padding is
based on the displayed text's ascent/baseline.

Change-Id: Id53e9bdc6e699fb05fdf331a6a472ecc170edf38
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
e2711cbb1569ab6c7a7c4506505ec403286d5ab4 28-May-2015 Justin Klaassen <justinklaassen@google.com> Update advanced pad layout

Bug: 7263319
Bug: 20841915

- Switch to using GridLayout instead of custom ViewGroup.
- Added '%' operator button (Note: evaluation support WIP).

Change-Id: I0d07f01fe4224c43e53c916b034362d906bea405
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
e4579121c8a9c9df22a35944ad5066d38dc22b37 27-May-2015 Hans Boehm <hboehm@google.com> Improve evaluate-ahead heuristic

Bug: 21447808

This changes the existing heuristics to compute ahead significantly
more aggressively. In my testing, this typically managed to prevent
blanks from being displayed even during rapid scrolling. We start
the next computation once we get near the end of what we've
currently computed. By the time we get to the end, the new
results are ready.

With this change, we typically compute to nearly 100 digits even
without scrolling, and the amount we compute ahead increases as
we've scrolled further. With the previous asin() CL, that seems to be
fine. I suspect, but have not confirmed, that for this size
BigInteger operations, much of the latency is fixed, e.g. JNI,
overhead, and the number of digits is not yet critical anyway.

This should reduce the total amount of computation, and hence battery
usage, during "extreme scrolling", since the evaluation precision
now increases geometrically.

Update a copyright notice.

Change-Id: If3a162016b8ffbacc872361aaa99c77c7fd578a2
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
61568a15c8d88d86aba14a7800d0bfb46f22c8ba 19-May-2015 Hans Boehm <hboehm@google.com> Prevent scrolling of finite results.

Bug: 20562484

Inhibit scrolling past the last nonzero digit when we can identify it.
Increase length of immediate result a bit, to make it closer to the
L calculator. On "=", expand less for scrollable results, more for
short non-scrollable results. This allows us to use larger fonts for
short finite results.

Fix up animation logic when displaying result. The old version was
never quite right, and became more visibly wrong with variable
enlargement. This version is simpler and seems to give much better
results.

This still does not add ellipsis at the right end of a result. But
it is now easily possible to tell whether a result is known finite by
attempting to scroll it. That may be good enough.

Remove some obsolete TODO entries.

Change-Id: I25a842a743e1c27191ca18ac69aa9eef0f0ea9b1
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
ffda52845ca6cca5f72795706988a11f6bcf5b03 19-May-2015 Hans Boehm <hboehm@google.com> Handle placeholder characters during translation

Bug: 21131556

If we fall behind, initially use blanks as placeholder characters.
Convert these to the right character (currently a correctly sized
space) during translation.

This avoids log spam by the translation code with minimal complication.
It also seems a bit cleaner.

Add some missing private qualifiers in the same vicinity.

Change-Id: I9c53d74ce2a234c888cee55ba72575c884f18cae
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
1176f23dae4d3740782e46463003e9f36a381c9d 12-May-2015 Hans Boehm <hboehm@google.com> Improve copy/paste handling, minor instant result fixes

Bug: 20764417
Bug: 20838790

Finish the action mode when we do almost anything else.
We should probably be even more aggressive about terminating it,
and we may eventually want to use a different approach.
But this avoids the crashes, and greatly improves the behavior.

Display copy menu only when there is something to copy.

Fix a couple of bugs introduced by recent instant display overhaul
(one line each):

- Instant display disappeared on rotation.

- It was sometimes still possible to scroll the previous result after
CLR.

Change-Id: I1a91d312358898add1e281aaba116d709b4c92a7
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
ecc69fd8b95a5910ad7e8a934da9700a087fe050 07-May-2015 Justin Klaassen <justinklaassen@google.com> Fix CHAR_LIMIT for strings

Bug: 20877857
Bug: 20815563

- Condensed strings to one string.xml with translatable="false".
- Made functions and digits NOT localized.
- Switched to U+2007 character for unknown digits.

Change-Id: I51a108309ccfa9c40edd6f87f9e052ba7ee25e3a
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
ed9e67864d9d54ed58ddb339a15115250d48bd30 02-May-2015 Hans Boehm <hboehm@google.com> Fix paste bug

Bug: 20764843

Pasting in a number changes the expression value. Duh.

Change-Id: Ia4234632833767fd3d8614f56feec9dcf123ae3c
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.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/Evaluator.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/Evaluator.java
08e8f322b0d93e06aaa2a15acc869dfd70791461 21-Apr-2015 Hans Boehm <hboehm@google.com> Restructure display formatting, use TextView for formula.

This fixes issues with inappropriate keyboard popups and cleans
up the code.

This substantially rewrites the result formatting code;
it intentionally removes a heuristic to avoid conventional scientific
notation for short results, which only seemed to confuse things.
There are some other tweaks and simplifications. Transitions
to and from conventional scientific notation should be smoother,
though there is still an issue with numbers like 10^-30.
The formatting code is completely extracted from Evaluator, cutting
off various tentacles, and moved to CalculatorResult.

Fixes a bug that resulted in digits being inappropriately
displayed without an exponent if the decimal point was just off
the left edge of the screen.

It's still not clear that we should always be integrating the
exponent into the result window.

Bug: 20483801
Bug: 20480081

Change-Id: I1bb777b871e9fa8b6cd510c533e4b94bde6d4a20
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java
760a9dc6573e35bcbf9097dece06cd90c4abb551 20-Apr-2015 Hans Boehm <hboehm@google.com> Fix result overlap, clear logic, display bugs, etc.

Adjust result padding to prevent overlapping with options menu,
resulting in inability to access options menu.

Reset state correctly after clear, preventing occasional crashes.
Do this at end of animation to prevent animation glitches.
Have clear but the display in a state in which COPY does
nothing interesting.

Treat a not-known-to-be-exact zero result better. Before this
we displayed it as just "0", giving the mistaken impression of
exactness. It is unclear whether we should display it as "0.00000000"
or add an exponent to indicate the real evaluation precision.
The former probably works better for beginners; the latter for
experts. We now do the former, which is probably right.

Also correctly save and restore not-yet analyzed characters.

Change-Id: Iac46d0d3b5a06f61beb6af7d4f0910e43284f52b
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.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/Evaluator.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/Evaluator.java
bfe8c22fd15ff965ed97c7245b49565c645c2cee 03-Apr-2015 Hans Boehm <hboehm@google.com> Add degree/radian mode, improve button layout

Add a button for switching between degree and radian mode.
Handle display updates in response to mode switching in a reasonoble way.
Improve the button layout so that it is usable on tablets.
Add DEG/RAD mode display at the top.
Fiddle with some of the layout parameters so they make more sense
to me.

This may need further tuning.

Change-Id: I8d04b235cfcb1f0a0d8f4a0ad6a0dc6e5eac8c5d
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.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/Evaluator.java
84614957604253d51296e06c97daced699a0a9de 26-Nov-2014 Hans Boehm <hboehm@google.com> Beginnings of ExactCalculator based on L

Replace the arity library with a new evaluation engine based on
an open source "constructive reals" library. This provides answers
that are correct to the last displayed digit, and can be scrolled to
get more precision, with evaluation to additional precision
proceeding on demand.

This uses pieces of an old prototype calculator with a
pre-Material-Design UI. Since the code structure of the KitKat and
Lollipop calculators is quite different, this merge required major
changes to make the pieces fit again. An egregious bug in the
prototype related to the evaluation of the power operator was
fixed. Many new UI bugs are introduced to compensate :-)

Add separate buttons for inverse trig functions.

Add long TODO lists for various missing pieces.

This is really designed to get something up and running
that looks like it has a Material Design UI.

This version kind of works, though with many UI deficiencies.

This addresses external issues 63368, 81089, and 80990. It
partially address the degree vs radian (80330) issue as well,
though we're still missing the UI for that.

This fixes

Bug:15284587

(More work is needed to make this interact correctly with keyboard support.)

Degree/Radian mode is also internal

Bug:17059768

This provides much more robust solutions to the following, which were
previously fixed by favoring round numbers over precise solutions:

Bug:15747298
Bug:15332726

Change-Id: Ib64ffcee9760a3195ae2a48302308eeb09a156bd
/packages/apps/ExactCalculator/src/com/android/calculator2/Evaluator.java