lua-l archive
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
] [
Date Index
] [
Thread Index
]
Subject
:
Re: Rounding a number to integer
From
: Egor Skriptunoff <egor.skriptunoff@
...
>
Date
: Wed, 3 Aug 2016 20:30:01 +0300
On Sun, Jul 31, 2016 at 9:33 PM, Roberto Ierusalimschy
<
roberto@inf.puc-rio.br
>
wrote:
What about this one?
function round (x)
return math.floor((x % 2.0 == 0.5) and x or x + 0.5)
end
> (2^52+1)|0, round(2^52+1)
4503599627370497 4503599627370498
Follow-Ups
:
Re: Rounding a number to integer
,
Dirk Laurie
Re: Rounding a number to integer
,
Roberto Ierusalimschy
References
:
Re: Rounding a number to integer
,
Roberto Ierusalimschy
Prev by Date:
Re: Rounding a number to integer
Next by Date:
Re: Rounding a number to integer
Previous by thread:
Re: Rounding a number to integer
Next by thread:
Re: Rounding a number to integer
Index(es):
Date
Thread