diff options
Diffstat (limited to 'src/pkg/bignum/arith.go')
| -rw-r--r-- | src/pkg/bignum/arith.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/pkg/bignum/arith.go b/src/pkg/bignum/arith.go index 068416729..243e34b9c 100644 --- a/src/pkg/bignum/arith.go +++ b/src/pkg/bignum/arith.go @@ -18,10 +18,10 @@ func Mul128(x, y uint64) (z1, z0 uint64) { // and return the product as 2 words. const ( - W = uint(unsafe.Sizeof(x))*8; - W2 = W/2; - B2 = 1<<W2; - M2 = B2-1; + W = uint(unsafe.Sizeof(x)) * 8; + W2 = W / 2; + B2 = 1 << W2; + M2 = B2 - 1; ) if x < y { @@ -32,7 +32,7 @@ func Mul128(x, y uint64) (z1, z0 uint64) { // y < B2 because y <= x // sub-digits of x and y are (0, x) and (0, y) // z = z[0] = x*y - z0 = x*y; + z0 = x * y; return; } @@ -43,13 +43,13 @@ func Mul128(x, y uint64) (z1, z0 uint64) { x1, x0 := x>>W2, x&M2; // x*y = t2*B2*B2 + t1*B2 + t0 - t0 := x0*y; - t1 := x1*y; + t0 := x0 * y; + t1 := x1 * y; // compute result digits but avoid overflow // z = z[1]*B + z[0] = x*y z0 = t1<<W2 + t0; - z1 = (t1 + t0>>W2)>>W2; + z1 = (t1 + t0>>W2) >> W2; return; } @@ -61,14 +61,14 @@ func Mul128(x, y uint64) (z1, z0 uint64) { y1, y0 := y>>W2, y&M2; // x*y = t2*B2*B2 + t1*B2 + t0 - t0 := x0*y0; + t0 := x0 * y0; t1 := x1*y0 + x0*y1; - t2 := x1*y1; + t2 := x1 * y1; // compute result digits but avoid overflow // z = z[1]*B + z[0] = x*y z0 = t1<<W2 + t0; - z1 = t2 + (t1 + t0>>W2)>>W2; + z1 = t2 + (t1+t0>>W2)>>W2; return; } @@ -80,10 +80,10 @@ func MulAdd128(x, y, c uint64) (z1, z0 uint64) { // and return the product as 2 words. const ( - W = uint(unsafe.Sizeof(x))*8; - W2 = W/2; - B2 = 1<<W2; - M2 = B2-1; + W = uint(unsafe.Sizeof(x)) * 8; + W2 = W / 2; + B2 = 1 << W2; + M2 = B2 - 1; ) // TODO(gri) Should implement special cases for faster execution. @@ -99,12 +99,12 @@ func MulAdd128(x, y, c uint64) (z1, z0 uint64) { // x*y + c = t2*B2*B2 + t1*B2 + t0 t0 := x0*y0 + c0; t1 := x1*y0 + x0*y1 + c1; - t2 := x1*y1; + t2 := x1 * y1; // compute result digits but avoid overflow // z = z[1]*B + z[0] = x*y z0 = t1<<W2 + t0; - z1 = t2 + (t1 + t0>>W2)>>W2; + z1 = t2 + (t1+t0>>W2)>>W2; return; } |
