diff options
| author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:35:38 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:35:38 -0800 |
| commit | e4bd81f903362d998f7bfc02095935408aff0bc5 (patch) | |
| tree | 05f75a90e239d33be427da4f9c5596d2fcb3dc96 /src/pkg/math/log.go | |
| parent | d9527dd16f72598b54a64550607bf892efa12384 (diff) | |
| download | golang-e4bd81f903362d998f7bfc02095935408aff0bc5.tar.gz | |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
3rd set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/180048
Diffstat (limited to 'src/pkg/math/log.go')
| -rw-r--r-- | src/pkg/math/log.go | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/pkg/math/log.go b/src/pkg/math/log.go index e92650131..0564689f4 100644 --- a/src/pkg/math/log.go +++ b/src/pkg/math/log.go @@ -76,15 +76,15 @@ package math // Log(NaN) = NaN func Log(x float64) float64 { const ( - Ln2Hi = 6.93147180369123816490e-01; /* 3fe62e42 fee00000 */ - Ln2Lo = 1.90821492927058770002e-10; /* 3dea39ef 35793c76 */ - L1 = 6.666666666666735130e-01; /* 3FE55555 55555593 */ - L2 = 3.999999999940941908e-01; /* 3FD99999 9997FA04 */ - L3 = 2.857142874366239149e-01; /* 3FD24924 94229359 */ - L4 = 2.222219843214978396e-01; /* 3FCC71C5 1D8E78AF */ - L5 = 1.818357216161805012e-01; /* 3FC74664 96CB03DE */ - L6 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */ - L7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ + Ln2Hi = 6.93147180369123816490e-01 /* 3fe62e42 fee00000 */ + Ln2Lo = 1.90821492927058770002e-10 /* 3dea39ef 35793c76 */ + L1 = 6.666666666666735130e-01 /* 3FE55555 55555593 */ + L2 = 3.999999999940941908e-01 /* 3FD99999 9997FA04 */ + L3 = 2.857142874366239149e-01 /* 3FD24924 94229359 */ + L4 = 2.222219843214978396e-01 /* 3FCC71C5 1D8E78AF */ + L5 = 1.818357216161805012e-01 /* 3FC74664 96CB03DE */ + L6 = 1.531383769920937332e-01 /* 3FC39A09 D078C69F */ + L7 = 1.479819860511658591e-01 /* 3FC2F112 DF3E5244 */ ) // special cases @@ -98,23 +98,23 @@ func Log(x float64) float64 { } // reduce - f1, ki := Frexp(x); + f1, ki := Frexp(x) if f1 < Sqrt2/2 { - f1 *= 2; - ki--; + f1 *= 2 + ki-- } - f := f1 - 1; - k := float64(ki); + f := f1 - 1 + k := float64(ki) // compute - s := f / (2 + f); - s2 := s * s; - s4 := s2 * s2; - t1 := s2 * (L1 + s4*(L3+s4*(L5+s4*L7))); - t2 := s4 * (L2 + s4*(L4+s4*L6)); - R := t1 + t2; - hfsq := 0.5 * f * f; - return k*Ln2Hi - ((hfsq - (s*(hfsq+R) + k*Ln2Lo)) - f); + s := f / (2 + f) + s2 := s * s + s4 := s2 * s2 + t1 := s2 * (L1 + s4*(L3+s4*(L5+s4*L7))) + t2 := s4 * (L2 + s4*(L4+s4*L6)) + R := t1 + t2 + hfsq := 0.5 * f * f + return k*Ln2Hi - ((hfsq - (s*(hfsq+R) + k*Ln2Lo)) - f) } // Log10 returns the decimal logarithm of x. @@ -123,5 +123,5 @@ func Log10(x float64) float64 { if x <= 0 { return NaN() } - return Log(x) * (1 / Ln10); + return Log(x) * (1 / Ln10) } |
