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/sin.go | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/pkg/math/sin.go') diff --git a/src/pkg/math/sin.go b/src/pkg/math/sin.go index 25f676355..e17daf688 100644 --- a/src/pkg/math/sin.go +++ b/src/pkg/math/sin.go @@ -8,32 +8,32 @@ package math func sinus(x float64, quad int) float64 { // Coefficients are #3370 from Hart & Cheney (18.80D). const ( - P0 = .1357884097877375669092680e8; - P1 = -.4942908100902844161158627e7; - P2 = .4401030535375266501944918e6; - P3 = -.1384727249982452873054457e5; - P4 = .1459688406665768722226959e3; - Q0 = .8644558652922534429915149e7; - Q1 = .4081792252343299749395779e6; - Q2 = .9463096101538208180571257e4; - Q3 = .1326534908786136358911494e3; + P0 = .1357884097877375669092680e8 + P1 = -.4942908100902844161158627e7 + P2 = .4401030535375266501944918e6 + P3 = -.1384727249982452873054457e5 + P4 = .1459688406665768722226959e3 + Q0 = .8644558652922534429915149e7 + Q1 = .4081792252343299749395779e6 + Q2 = .9463096101538208180571257e4 + Q3 = .1326534908786136358911494e3 ) if x < 0 { - x = -x; - quad = quad + 2; + x = -x + quad = quad + 2 } - x = x * (2 / Pi); /* underflow? */ - var y float64; + x = x * (2 / Pi) /* underflow? */ + var y float64 if x > 32764 { - var e float64; - e, y = Modf(x); - e = e + float64(quad); - f, _ := Modf(0.25 * e); - quad = int(e - 4*f); + var e float64 + e, y = Modf(x) + e = e + float64(quad) + f, _ := Modf(0.25 * e) + quad = int(e - 4*f) } else { - k := int32(x); - y = x - float64(k); - quad = (quad + int(k)) & 3; + k := int32(x) + y = x - float64(k) + quad = (quad + int(k)) & 3 } if quad&1 != 0 { @@ -43,10 +43,10 @@ func sinus(x float64, quad int) float64 { y = -y } - yy := y * y; - temp1 := ((((P4*yy+P3)*yy+P2)*yy+P1)*yy + P0) * y; - temp2 := ((((yy+Q3)*yy+Q2)*yy+Q1)*yy + Q0); - return temp1 / temp2; + yy := y * y + temp1 := ((((P4*yy+P3)*yy+P2)*yy+P1)*yy + P0) * y + temp2 := ((((yy+Q3)*yy+Q2)*yy+Q1)*yy + Q0) + return temp1 / temp2 } // Cos returns the cosine of x. @@ -54,8 +54,8 @@ func Cos(x float64) float64 { if x < 0 { x = -x } - return sinus(x, 1); + return sinus(x, 1) } // Sin returns the sine of x. -func Sin(x float64) float64 { return sinus(x, 0) } +func Sin(x float64) float64 { return sinus(x, 0) } -- cgit v1.2.3