Menu Close

Go – How to get the least integer value of number in go

Here, We will learn how to get the least integer value of a number in go. We can get it by using Ceil() function in math package in go golang.

Function prototype:

func Ceil(no float64) float64

Return value:

Ceil() function in math package returns
the least integer value greater than or

equal to number.

Example with code:

package main

import (

func main() {

  no := math.Ceil(2.51)
  fmt.Printf("%.1f\n", no)

  no = math.Ceil(2.39)
  fmt.Printf("%.1f\n", no)

  no = math.Ceil(3.12)
  fmt.Printf("%.1f\n", no)

  no = math.Ceil(-3.21)
  fmt.Printf("%.1f\n", no)



To learn more about golang, Please refer given below link:

Posted in golang, math

Leave a Reply

Your email address will not be published. Required fields are marked *