Seuntjies DiceBot

DiceBot => Programmer Mode => Topic started by: Voodoohack on August 01, 2020, 01:36:49 am

Title: Round a variables value
Post by: Voodoohack on August 01, 2020, 01:36:49 am
I've tried nextbet = mathfloor(Var, 0.000005) but it doesn't work for some reason :(( help?
Title: Re: Round a variables value
Post by: Seuntjie on August 01, 2020, 01:34:11 pm
For one thing, the syntax is math.floor, not mathfloor. The dot is important.

Secondly, floor rounds DOWN to the closest INTEGER. in other words math.floor(0.999999) will return 0. math.floor(100.99999999) will return 100. So it is doing exactly what it should, just not what you need.

Doing a web search for simply 'lua round' provided this result that seems like a pretty resource: http://lua-users.org/wiki/SimpleRound