Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify stripTrailingZeros #1273

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ object SafeNumbers {
y = q1
z = q1
}
if (r1 == 0) return q1
y
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ object SafeNumbers {
val s = vb >> 2
if (
s < 100 || {
dv = Math.multiplyHigh(s, 1844674407370955168L)
dv = Math.multiplyHigh(s, 1844674407370955168L) // divide a positive long by 10
val sp40 = dv * 40
val upin = (vbls - sp40).toInt
(((sp40 + vbrd).toInt + 40) ^ upin) >= 0 || {
Expand Down Expand Up @@ -276,16 +276,11 @@ object SafeNumbers {
(x - q0 * 100000000L).toInt == 0
}
) return stripTrailingZeros(q0).toLong
var y = x
var q1, r1 = 0L
var y, q1 = x
while ({
q1 = y / 100
r1 = y - q1 * 100
r1 == 0
q1 = Math.multiplyHigh(q1, 1844674407370955168L) // divide a positive long by 10
q1 * 10 == y
}) y = q1
q1 = y / 10
r1 = y - q1 * 10
if (r1 == 0) return q1
y
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ object SafeNumbers {
val s = vb >> 2
if (
s < 100 || {
dv = s / 10
dv = NativeMath.multiplyHigh(s, 1844674407370955168L) // divide a positive long by 10
val sp40 = dv * 40
val upin = (vbls - sp40).toInt
(((sp40 + vbrd).toInt + 40) ^ upin) >= 0 || {
Expand Down Expand Up @@ -276,16 +276,11 @@ object SafeNumbers {
(x - q0 * 100000000L).toInt == 0
}
) return stripTrailingZeros(q0).toLong
var y = x
var q1, r1 = 0L
var y, q1 = x
while ({
q1 = y / 100
r1 = y - q1 * 100
r1 == 0
q1 = NativeMath.multiplyHigh(q1, 1844674407370955168L) // divide a positive long by 10
q1 * 10 == y
}) y = q1
q1 = y / 10
r1 = y - q1 * 10
if (r1 == 0) return q1
y
}

Expand Down