[Tarantool-patches] [PATCH luajit] x86/x64: Fix math.ceil(-0.9) result sign.

Sergey Bronnikov sergeyb at tarantool.org
Thu Nov 9 16:26:29 MSK 2023


Hi, Sergey

thanks for the patch! LGTM

see a minor comment below

On 11/2/23 15:36, Sergey Kaplun wrote:


<snipped>

> +++ b/test/tarantool-tests/lj-859-math-ceil-sign.test.lua
> @@ -0,0 +1,20 @@
> +local tap = require('tap')
> +
> +-- Test file to demonstrate the incorrect LuaJIT's behaviour
> +-- for `math.ceil(x)` when argument `x`: -1 < x < -0.5.
> +-- See also https://github.com/LuaJIT/LuaJIT/issues/859.
> +
> +local test = tap.test('lj-859-math-ceil-sign')
> +
> +test:plan(1)
> +
> +local IS_DUALNUM = tostring(tonumber('-0')) ~= tostring(-0)
> +local IS_X86_64 = jit.arch == 'x86' or jit.arch == 'x64'
> +
> +-- Use `tostirng()` to compare sign of the returned value.

tostirng -> tostring


> +-- Take any value from the mentioned range. Chosen one is
> +-- mentioned in the commit message.
> +test:ok((IS_DUALNUM and IS_X86_64) or tostring(math.ceil(-0.9)) == '-0',
> +        'correct zero sign')
> +
> +test:done(true)


More information about the Tarantool-patches mailing list