lua-users home
lua-l archive

Re: Why is there no 'math.round'?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


What's the specific request that we are trying to define? math.round(value, precision) for non-integer rounding?

I'm confused about what is being requested. I agree with the earlier observation that floor/ceil give us everything we need:

> a = 12.345678
> print(math.floor(a+0.5))
12
> print(math.floor(a*10+0.5)/10)
12.3
> print(math.floor(a*100+0.5)/100)
12.35

Am I missing something very obscure?


AltStyle によって変換されたページ (->オリジナル) /