summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java
diff options
context:
space:
mode:
authorrepo sync <enh@google.com>2011-01-12 18:55:27 -0800
committerrepo sync <enh@google.com>2011-01-12 18:55:27 -0800
commitf74c8a0e66b6869d3b3bb4a30bf2f089e350980e (patch)
treeceab07adf64482dccf523bbdb91e60d539f203a3 /luni/src/main/java
parentfb641fa5146f95c7571c939616bdc11384319dc0 (diff)
parent4f7abf2ac9af897f86b6fb6f38024de0988d58b7 (diff)
downloadlibcore-f74c8a0e66b6869d3b3bb4a30bf2f089e350980e.zip
libcore-f74c8a0e66b6869d3b3bb4a30bf2f089e350980e.tar.gz
libcore-f74c8a0e66b6869d3b3bb4a30bf2f089e350980e.tar.bz2
resolved conflicts for merge of 4f7abf2a to honeycomb-plus-aosp
Change-Id: Ieaf43d93b158ab143601b874c872570c3c3fe98b
Diffstat (limited to 'luni/src/main/java')
-rw-r--r--luni/src/main/java/java/lang/RealToString.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/luni/src/main/java/java/lang/RealToString.java b/luni/src/main/java/java/lang/RealToString.java
index 3dea2dc..31203eb 100644
--- a/luni/src/main/java/java/lang/RealToString.java
+++ b/luni/src/main/java/java/lang/RealToString.java
@@ -26,7 +26,7 @@ final class RealToString {
}
};
- private final static double invLogOfTenBaseTwo = Math.log(2.0) / Math.log(10.0);
+ private static final double invLogOfTenBaseTwo = Math.log(2.0) / Math.log(10.0);
private int firstK;
@@ -287,8 +287,15 @@ final class RealToString {
boolean low, high;
int U;
while (true) {
- U = (int) (R / S);
- R = R - U*S; // Faster than "R = R % S" on nexus one, which only has hardware MUL.
+ // Set U to floor(R/S) and R to the remainder, using *unsigned* 64-bit division
+ U = 0;
+ for (int i = 3; i >= 0; i--) {
+ long remainder = R - (S << i);
+ if (remainder >= 0) {
+ R = remainder;
+ U += 1 << i;
+ }
+ }
low = R < M; // was M_minus
high = R + M > S; // was M_plus