# Golang math.Floor() Function

Golang math.Floor() function is “used to find the rounded-down or the floor value of a decimal number.

## Syntax

``func Floor(x float64) float64``

## Parameters

x: The function accepts only one argument of type float64.

There are some exceptions I would like to mention here.

1. Inf: If you pass an infinite value(±Inf), the return value will be the same as the argument.
2. NAN: If you pass a NAN value, it returns NAN.
3. 0: If you pass the (±)0 argument, it returns the same value as an argument.

## Return value

The Floor() function returns a single value of the argument rounded down to the nearest whole number whose data type is float64.

## Example 1: Use of math.Floor() function

To use the math.Floor() function, import a math package.

``````package main

import (
"fmt"
"math"
"reflect"
)

func main() {
var floating_point = 19.21
fmt.Println(floating_point)
fmt.Print("The data type is: ", reflect.TypeOf(floating_point), "\n")

var rounded_down = math.Floor(floating_point)
fmt.Println(rounded_down)
fmt.Print("The data type is: ", reflect.TypeOf(rounded_down), "\n")
}
``````

Output

``````19.21
The data type is: float64
19
The data type is: float64``````

## Example 2: Passing Inf, NAN, and 0

Inf means infinite value, and NAN means not a number and 0. Inf can be positive or negative.

``````package main

import (
"fmt"
"math"
)

func main() {
var infinity = math.Inf(-1)
var notANumber = math.NaN()
var zero = 0

fmt.Println(infinity)
fmt.Println(notANumber)
fmt.Println(zero)
}
``````

Output

``````-Inf
NaN
0``````

That’s it!

Go math.Exp()

Go math.Dim()

Go math.Cbrt()

Go math.Pow()

Go math.round()