How to find the floor value of a number using math.floor() function in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println(math.Floor(50))
	fmt.Println(math.Floor(50.1))
	fmt.Println(math.Floor(5.4))
	fmt.Println(math.Floor(5.5))
	fmt.Println(math.Floor(5.6))
	fmt.Println(math.Floor(-10))
	fmt.Println(math.Floor(-13.4))
	fmt.Println(math.Floor(-13.5))
	fmt.Println(math.Floor(-13.6))
	fmt.Println(math.Floor(0))
}


/*
run:

50
50
5
5
5
-10
-14
-14
-14
0

*/

 



answered Aug 10, 2024 by avibootz
...