diff options
author | Hans Boehm <hboehm@google.com> | 2015-06-22 17:18:52 -0700 |
---|---|---|
committer | Hans Boehm <hboehm@google.com> | 2015-06-23 15:12:12 -0700 |
commit | 5e802f30a0f18df4e2ecbf030e4aebb4ee70e8e8 (patch) | |
tree | 29e1571959443ad6e38784fdeea5ee4d9b9560a2 /tests | |
parent | aafeaa046712478381b4d762437c2b756c3fac1c (diff) | |
download | android_packages_apps_ExactCalculator-5e802f30a0f18df4e2ecbf030e4aebb4ee70e8e8.tar.gz android_packages_apps_ExactCalculator-5e802f30a0f18df4e2ecbf030e4aebb4ee70e8e8.tar.bz2 android_packages_apps_ExactCalculator-5e802f30a0f18df4e2ecbf030e4aebb4ee70e8e8.zip |
Correct off-by-1 errors in display formatting code.
Bug: 21986868
Bug: 21960281
Fix and restructure the formatting and scroll-limit-calculation
code. This code is inherently tricky, and has had more bugs than
we would like to admit to. Use the opportunity to clean up the
code a bit, renaming variables consistently.
The good news is that the code seems to be getting slightly
simpler with each bug fix.
This fixes several separate off-by-one errors related to result
formatting:
The expLen() exponent string length calculation was off by 1
for exact powers of 10.
The dropDigits calculation in the formatting code was off for
negative exponents just shorter than an exact power of 10.
The exponent space calculation for a few results like -1.2*10^-8
was off by one.
For a result like -10^-500 we did not reserve space for the leading
minus sign, since that's not computed until after scrolling.
[Less serious] The ellipses were omitted when we had just barely
scrolled a leading minus sign off the screen. (This only occurred
in exactly one position, which could never be the default one.)
Change-Id: If1bfbbb70a624998be3d996592d129b16aade745
Diffstat (limited to 'tests')
-rw-r--r-- | tests/README.txt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/README.txt b/tests/README.txt index b1cd968..ee64f0c 100644 --- a/tests/README.txt +++ b/tests/README.txt @@ -19,3 +19,25 @@ is used by the calculator mostly to identify exact results, i.e. terminating decimal expansions. But it's also used to optimize CR computations, and bugs in BoundedRational could result in incorrect outputs.) + +We currently have no automatic tests for display formatting corner cases. +The following numbers have exhibited problems in the past and would be good +to test. Some of them are difficult to test automatically, because they +require scrolling to both ends of the result. For those with finite +decimal expansions, it also worth confirming that the "display with leading +digits" display shows an exact value when scrolled all the way to the right. + +Some interesting test cases: + +10^10 + 10^30 +10^30 + 10^-10 +-10^30 + 20 +10^30 + 10^-30 +-10^30 - 10^10 +-1.2x10^-9 +-1.2x10^-8 +1 - 10^-98 +1 - 10^-100 +1 - 10^-300 +1/-56x10^18 (on a Nexus 7 sized portrait display) +-10^-500 (scroll to see the 1, then scroll back & verify minus sign appears) |