I would like to create a function floor(number, step), which acts like :
floor(0, 1) = 0
floor(1, 1) = 1
floor(1, 2) = 0
floor(5, 2) = 4
floor(.8, .25) = .75
What is the better way to do something like that ?
Thanks.
You could do something like floor( val / step ) * step
what you want is basically the same as
step * (x // step)
isn't ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With