From e4bd81f903362d998f7bfc02095935408aff0bc5 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 15 Dec 2009 15:35:38 -0800 Subject: 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 --- src/pkg/math/exp.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/pkg/math/exp.go') diff --git a/src/pkg/math/exp.go b/src/pkg/math/exp.go index cdee0d70a..9ad2b3877 100644 --- a/src/pkg/math/exp.go +++ b/src/pkg/math/exp.go @@ -90,18 +90,18 @@ package math // Very small values underflow to 1. func Exp(x float64) float64 { const ( - Ln2Hi = 6.93147180369123816490e-01; - Ln2Lo = 1.90821492927058770002e-10; - Log2e = 1.44269504088896338700e+00; - P1 = 1.66666666666666019037e-01; /* 0x3FC55555; 0x5555553E */ - P2 = -2.77777777770155933842e-03; /* 0xBF66C16C; 0x16BEBD93 */ - P3 = 6.61375632143793436117e-05; /* 0x3F11566A; 0xAF25DE2C */ - P4 = -1.65339022054652515390e-06; /* 0xBEBBBD41; 0xC5D26BF1 */ - P5 = 4.13813679705723846039e-08; /* 0x3E663769; 0x72BEA4D0 */ + Ln2Hi = 6.93147180369123816490e-01 + Ln2Lo = 1.90821492927058770002e-10 + Log2e = 1.44269504088896338700e+00 + P1 = 1.66666666666666019037e-01 /* 0x3FC55555; 0x5555553E */ + P2 = -2.77777777770155933842e-03 /* 0xBF66C16C; 0x16BEBD93 */ + P3 = 6.61375632143793436117e-05 /* 0x3F11566A; 0xAF25DE2C */ + P4 = -1.65339022054652515390e-06 /* 0xBEBBBD41; 0xC5D26BF1 */ + P5 = 4.13813679705723846039e-08 /* 0x3E663769; 0x72BEA4D0 */ - Overflow = 7.09782712893383973096e+02; - Underflow = -7.45133219101941108420e+02; - NearZero = 1.0 / (1 << 28); // 2^-28 + Overflow = 7.09782712893383973096e+02 + Underflow = -7.45133219101941108420e+02 + NearZero = 1.0 / (1 << 28) // 2^-28 ) // special cases @@ -119,21 +119,21 @@ func Exp(x float64) float64 { } // reduce; computed as r = hi - lo for extra precision. - var k int; + var k int switch { case x < 0: k = int(Log2e*x - 0.5) case x > 0: k = int(Log2e*x + 0.5) } - hi := x - float64(k)*Ln2Hi; - lo := float64(k) * Ln2Lo; - r := hi - lo; + hi := x - float64(k)*Ln2Hi + lo := float64(k) * Ln2Lo + r := hi - lo // compute - t := r * r; - c := r - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); - y := 1 - ((lo - (r*c)/(2-c)) - hi); + t := r * r + c := r - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))) + y := 1 - ((lo - (r*c)/(2-c)) - hi) // TODO(rsc): make sure Ldexp can handle boundary k - return Ldexp(y, k); + return Ldexp(y, k) } -- cgit v1.2.3