github.com/s1s1ty/go@v0.0.0-20180207192209-104445e3140f/src/math/example_test.go (about)

     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  }