runtime: abort stack scan in cases that we cannot unwind the stack
[gcc.git] / libgo / go / math / example_test.go
1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package math_test
6
7 import (
8 "fmt"
9 "math"
10 )
11
12 func ExampleAcos() {
13 fmt.Printf("%.2f", math.Acos(1))
14 // Output: 0.00
15 }
16
17 func ExampleAcosh() {
18 fmt.Printf("%.2f", math.Acosh(1))
19 // Output: 0.00
20 }
21
22 func ExampleAsin() {
23 fmt.Printf("%.2f", math.Asin(0))
24 // Output: 0.00
25 }
26
27 func ExampleAsinh() {
28 fmt.Printf("%.2f", math.Asinh(0))
29 // Output: 0.00
30 }
31
32 func ExampleAtan() {
33 fmt.Printf("%.2f", math.Atan(0))
34 // Output: 0.00
35 }
36
37 func ExampleAtan2() {
38 fmt.Printf("%.2f", math.Atan2(0, 0))
39 // Output: 0.00
40 }
41
42 func ExampleAtanh() {
43 fmt.Printf("%.2f", math.Atanh(0))
44 // Output: 0.00
45 }
46
47 func ExampleCos() {
48 fmt.Printf("%.2f", math.Cos(math.Pi/2))
49 // Output: 0.00
50 }
51
52 func ExampleCosh() {
53 fmt.Printf("%.2f", math.Cosh(0))
54 // Output: 1.00
55 }
56
57 func ExampleSin() {
58 fmt.Printf("%.2f", math.Sin(math.Pi))
59 // Output: 0.00
60 }
61
62 func ExampleSincos() {
63 sin, cos := math.Sincos(0)
64 fmt.Printf("%.2f, %.2f", sin, cos)
65 // Output: 0.00, 1.00
66 }
67
68 func ExampleSinh() {
69 fmt.Printf("%.2f", math.Sinh(0))
70 // Output: 0.00
71 }
72
73 func ExampleTan() {
74 fmt.Printf("%.2f", math.Tan(0))
75 // Output: 0.00
76 }
77
78 func ExampleTanh() {
79 fmt.Printf("%.2f", math.Tanh(0))
80 // Output: 0.00
81 }
82
83 func ExampleSqrt() {
84 const (
85 a = 3
86 b = 4
87 )
88 c := math.Sqrt(a*a + b*b)
89 fmt.Printf("%.1f", c)
90 // Output: 5.0
91 }
92
93 func ExampleCeil() {
94 c := math.Ceil(1.49)
95 fmt.Printf("%.1f", c)
96 // Output: 2.0
97 }
98
99 func ExampleFloor() {
100 c := math.Floor(1.51)
101 fmt.Printf("%.1f", c)
102 // Output: 1.0
103 }
104
105 func ExamplePow() {
106 c := math.Pow(2, 3)
107 fmt.Printf("%.1f", c)
108 // Output: 8.0
109 }
110
111 func ExamplePow10() {
112 c := math.Pow10(2)
113 fmt.Printf("%.1f", c)
114 // Output: 100.0
115 }
116
117 func ExampleRound() {
118 p := math.Round(10.5)
119 fmt.Printf("%.1f\n", p)
120
121 n := math.Round(-10.5)
122 fmt.Printf("%.1f\n", n)
123 // Output:
124 // 11.0
125 // -11.0
126 }
127
128 func ExampleRoundToEven() {
129 u := math.RoundToEven(11.5)
130 fmt.Printf("%.1f\n", u)
131
132 d := math.RoundToEven(12.5)
133 fmt.Printf("%.1f\n", d)
134 // Output:
135 // 12.0
136 // 12.0
137 }