LoginSignup
0
1

More than 3 years have passed since last update.

競プロで使うための GO 入門 ~math パッケージ~

Posted at

Index

math

package main

import (
    "fmt"
    "math" // math
)

func main() {
}

Abs()

var f float64 = 12.3456
fmt.Println(math.Abs(-1)) // ->1
fmt.Println(math.Abs(1)) // ->1

Cbrt()

func Cbrt(x float64) float64

Ceil()

func Ceil(x float64) float64

Floor()

func Floor(x float64) float64

Pow()

func Pow(x, y float64) float64

Round()

func Round(x float64) float64

var f float64 = 12.3456
fmt.Println(math.Round(f * 100) / 100)   // ->12.35
fmt.Println(math.Round(f * 1000) / 1000) // ->12.346
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1