github.com/go-eden/common@v0.1.15-0.20210617133546-059099253264/emath/math_calc.go (about)

     1  package emath
     2  
     3  func DivCeil(dividend, divisor int) (result int) {
     4  	if divisor == 0 {
     5  		panic("division can't be 0")
     6  	}
     7  	result = dividend / divisor
     8  	if dividend%divisor != 0 {
     9  		result++
    10  	}
    11  	return
    12  }
    13  
    14  func DivRound(dividend, divisor int) (result int) {
    15  	if divisor == 0 {
    16  		panic("division can't be 0")
    17  	}
    18  	result = dividend / divisor
    19  	if dividend%divisor >= divisor/2 {
    20  		result++
    21  	}
    22  	return
    23  }