OXIESEC PANEL
- Current Dir:
/
/
opt
/
golang
/
1.19.4
/
src
/
math
/
big
Server IP: 191.96.63.230
Upload:
Create Dir:
Name
Size
Modified
Perms
๐
..
-
12/01/2022 06:13:56 PM
rwxr-xr-x
๐
accuracy_string.go
414 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
alias_test.go
8.81 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith.go
8.28 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_386.s
4.07 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_amd64.go
306 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_amd64.s
9.09 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_arm.s
4.03 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_arm64.s
11.88 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_decl.go
594 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_decl_pure.go
1.04 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_decl_s390x.go
531 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_loong64.s
745 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_mips64x.s
817 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_mipsx.s
809 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_ppc64x.s
16.36 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_riscv64.s
786 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_s390x.s
20.32 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_s390x_test.go
812 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_test.go
19.88 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
arith_wasm.s
641 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
bits_test.go
5.07 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
calibrate_test.go
4.63 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
decimal.go
6.63 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
decimal_test.go
3.33 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
doc.go
3.79 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
example_rat_test.go
1.68 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
example_test.go
4.05 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
float.go
44.28 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
float_test.go
51.94 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
floatconv.go
8.34 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
floatconv_test.go
24.27 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
floatexample_test.go
3.63 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
floatmarsh.go
3.53 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
floatmarsh_test.go
3.92 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
ftoa.go
13.55 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
gcd_test.go
2.16 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
hilbert_test.go
2.88 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
int.go
30.26 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
int_test.go
53.14 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
intconv.go
6.69 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
intconv_test.go
10.01 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
intmarsh.go
2.14 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
intmarsh_test.go
3.07 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
link_test.go
1.4 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
nat.go
26.73 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
nat_test.go
23.56 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
natconv.go
14.55 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
natconv_test.go
16.85 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
natdiv.go
34.15 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
prime.go
10.34 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
prime_test.go
7.1 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
rat.go
13.47 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
rat_test.go
18.89 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
ratconv.go
9.78 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
ratconv_test.go
15.75 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
ratmarsh.go
2.1 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
ratmarsh_test.go
3.3 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
roundingmode_string.go
501 bytes
12/01/2022 06:12:59 PM
rw-r--r--
๐
sqrt.go
2.79 KB
12/01/2022 06:12:59 PM
rw-r--r--
๐
sqrt_test.go
4.81 KB
12/01/2022 06:12:59 PM
rw-r--r--
Editing: sqrt.go
Close
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package big import ( "math" "sync" ) var threeOnce struct { sync.Once v *Float } func three() *Float { threeOnce.Do(func() { threeOnce.v = NewFloat(3.0) }) return threeOnce.v } // Sqrt sets z to the rounded square root of x, and returns it. // // If z's precision is 0, it is changed to x's precision before the // operation. Rounding is performed according to z's precision and // rounding mode, but z's accuracy is not computed. Specifically, the // result of z.Acc() is undefined. // // The function panics if z < 0. The value of z is undefined in that // case. func (z *Float) Sqrt(x *Float) *Float { if debugFloat { x.validate() } if z.prec == 0 { z.prec = x.prec } if x.Sign() == -1 { // following IEEE754-2008 (section 7.2) panic(ErrNaN{"square root of negative operand"}) } // handle ยฑ0 and +โ if x.form != finite { z.acc = Exact z.form = x.form z.neg = x.neg // IEEE754-2008 requires โยฑ0 = ยฑ0 return z } // MantExp sets the argument's precision to the receiver's, and // when z.prec > x.prec this will lower z.prec. Restore it after // the MantExp call. prec := z.prec b := x.MantExp(z) z.prec = prec // Compute โ(zยท2**b) as // โ( z)ยท2**(ยฝb) if b is even // โ(2z)ยท2**(โยฝbโ) if b > 0 is odd // โ(ยฝz)ยท2**(โยฝbโ) if b < 0 is odd switch b % 2 { case 0: // nothing to do case 1: z.exp++ case -1: z.exp-- } // 0.25 <= z < 2.0 // Solving 1/xยฒ - z = 0 avoids Quo calls and is faster, especially // for high precisions. z.sqrtInverse(z) // re-attach halved exponent return z.SetMantExp(z, b/2) } // Compute โx (to z.prec precision) by solving // // 1/tยฒ - x = 0 // // for t (using Newton's method), and then inverting. func (z *Float) sqrtInverse(x *Float) { // let // f(t) = 1/tยฒ - x // then // g(t) = f(t)/f'(t) = -ยฝt(1 - xtยฒ) // and the next guess is given by // t2 = t - g(t) = ยฝt(3 - xtยฒ) u := newFloat(z.prec) v := newFloat(z.prec) three := three() ng := func(t *Float) *Float { u.prec = t.prec v.prec = t.prec u.Mul(t, t) // u = tยฒ u.Mul(x, u) // = xtยฒ v.Sub(three, u) // v = 3 - xtยฒ u.Mul(t, v) // u = t(3 - xtยฒ) u.exp-- // = ยฝt(3 - xtยฒ) return t.Set(u) } xf, _ := x.Float64() sqi := newFloat(z.prec) sqi.SetFloat64(1 / math.Sqrt(xf)) for prec := z.prec + 32; sqi.prec < prec; { sqi.prec *= 2 sqi = ng(sqi) } // sqi = 1/โx // x/โx = โx z.Mul(x, sqi) } // newFloat returns a new *Float with space for twice the given // precision. func newFloat(prec2 uint32) *Float { z := new(Float) // nat.make ensures the slice length is > 0 z.mant = z.mant.make(int(prec2/_W) * 2) return z }