Giter Site home page Giter Site logo

Comments (5)

haiyux avatar haiyux commented on September 14, 2024

return int64(math.Floor(float64(l.maxPASS()*l.minRT()*l.bucketPerSecond)/1000.0) + 0.5)

最后加的那个0.5是不是放错位置了。Floor函数返回的已经是一个整数值,在加 0.5 后,会被最外层的 int64() 截断吧

+0.5 是为了向上取整

from aegis.

DZGodly avatar DZGodly commented on September 14, 2024

return int64(math.Floor(float64(l.maxPASS()*l.minRT()*l.bucketPerSecond)/1000.0) + 0.5)

最后加的那个0.5是不是放错位置了。Floor函数返回的已经是一个整数值,在加 0.5 后,会被最外层的 int64() 截断吧

+0.5 是为了向上取整

加错位置了吧,应该先加 0.5 再进行 Floor 操作吧

from aegis.

juwell avatar juwell commented on September 14, 2024

why not use math.Ceil() to get value greater than or equal to x ?

the comment for Ceil

// Ceil returns the least integer value greater than or equal to x.
//
// Special cases are:
//	Ceil(±0) = ±0
//	Ceil(±Inf) = ±Inf
//	Ceil(NaN) = NaN
func Ceil(x float64) float64

from aegis.

lxkaka avatar lxkaka commented on September 14, 2024

not same with +0.5

from aegis.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.