From 385877a5deec37f38c33b4e927d887e9b9ead592 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 21 Mar 2013 13:53:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.go => ebook/build.go | 0 build.sh => ebook/build.sh | 0 genepub.sh => ebook/genepub.sh | 0 ebook/src/1.2/main.go | 13 +++++++++++++ ebook/src/1.2/sqrt.go | 11 +++++++++++ 5 files changed, 24 insertions(+) rename build.go => ebook/build.go (100%) rename build.sh => ebook/build.sh (100%) mode change 100755 => 100644 rename genepub.sh => ebook/genepub.sh (100%) mode change 100755 => 100644 create mode 100644 ebook/src/1.2/main.go create mode 100644 ebook/src/1.2/sqrt.go diff --git a/build.go b/ebook/build.go similarity index 100% rename from build.go rename to ebook/build.go diff --git a/build.sh b/ebook/build.sh old mode 100755 new mode 100644 similarity index 100% rename from build.sh rename to ebook/build.sh diff --git a/genepub.sh b/ebook/genepub.sh old mode 100755 new mode 100644 similarity index 100% rename from genepub.sh rename to ebook/genepub.sh diff --git a/ebook/src/1.2/main.go b/ebook/src/1.2/main.go new file mode 100644 index 00000000..132c60a7 --- /dev/null +++ b/ebook/src/1.2/main.go @@ -0,0 +1,13 @@ +// 章节 1.2 +// $GOPATH/src/mathapp/main.go + +package main + +import ( + "fmt" + "mymath" +) + +func main() { + fmt.Printf("Hello, world. Sqrt(2) = %v\n", mymath.Sqrt(2)) +} diff --git a/ebook/src/1.2/sqrt.go b/ebook/src/1.2/sqrt.go new file mode 100644 index 00000000..1d596053 --- /dev/null +++ b/ebook/src/1.2/sqrt.go @@ -0,0 +1,11 @@ +// 章节 1.2 +// $GOPATH/src/mymath/sqrt.go +package mymath + +func Sqrt(x float64) float64 { + z := 0.0 + for i := 0; i < 1000; i++ { + z -= (z*z - x) / (2 * x) + } + return z +}