|
Essentially by IEEE 0.5 should round to 0, and 1.5 to 2.
```lua
function rint(x)
if x < 0 then
return ((x - 0x1p+52) + 0x1p+52) | 0
end
return ((x + 0x1p+52) - 0x1p+52) | 0
end
```
If your argument is not expressible as an integer then this will cause an error so you should wrap it in `pcall` if the argument could be larger than `math.maxinteger` (or smaller than `math.mininteger`).