Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit] x86/x64: Fix math.ceil(-0.9) result sign.
Date: Thu, 23 Nov 2023 06:31:24 +0000	[thread overview]
Message-ID: <ZV7xvB9MTFJCv8qj@tarantool.org> (raw)
In-Reply-To: <20231102123616.10527-1-skaplun@tarantool.org>

Sergey,

I've checked the patchset into all long-term branches in
tarantool/luajit and bumped a new version in master, release/2.11 and
release/2.10.

On 02.11.23, Sergey Kaplun via Tarantool-patches wrote:
> From: Mike Pall <mike>
> 
> Reported by minoki.
> 
> (cherry-picked from commit 674afcd4e21d0cf64de3219d347557a0aed8ecc7)
> 
> The `ceil` (`floor`) math function implementation calculates (|x| +
> 2^52) - 2^52 for its argument to determine the fractional part of x , so
> it will be rounded to the nearest integer and its sign is restored.
> After that, if the original value is < (>) than the result, the -1 (1)
> is subtracted from it. Take a look at the `ceil()` case. The result of
> the operation `-1 - (-1)` is +0 for FP arithmetic, against -0 expected
> as a result.
> 
> This patch changes the `- (-1)` operation to `+ 1` and restores sign
> after it again.
> 
> NB: Since in DUALNUM mode on x86/x64 all results are tried to be
> converted to integers the sign of 0 is neglected.
> 
> Sergey Kaplun:
> * added the description and the test for the problem
> 
> Part of tarantool/tarantool#9145
> ---
> 
> Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-859-math-ceil-sign
> Tarantool PR: https://github.com/tarantool/tarantool/pull/9326
> Related issues:
> * https://github.com/LuaJIT/LuaJIT/issues/859
> * https://github.com/tarantool/tarantool/issues/9145
> 
>  src/vm_x64.dasc                               | 13 ++++++------
>  src/vm_x86.dasc                               | 13 ++++++------
>  .../lj-859-math-ceil-sign.test.lua            | 20 +++++++++++++++++++
>  3 files changed, 32 insertions(+), 14 deletions(-)
>  create mode 100644 test/tarantool-tests/lj-859-math-ceil-sign.test.lua
> 

<snipped>

> -- 
> 2.42.0
> 

-- 
Best regards,
IM

      parent reply	other threads:[~2023-11-23  6:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 12:36 Sergey Kaplun via Tarantool-patches
2023-11-07  9:44 ` Maxim Kokryashkin via Tarantool-patches
2023-11-07 10:21   ` Sergey Kaplun via Tarantool-patches
2023-11-07 10:50     ` Maxim Kokryashkin via Tarantool-patches
2023-11-09 13:26 ` Sergey Bronnikov via Tarantool-patches
2023-11-09 14:32   ` Sergey Kaplun via Tarantool-patches
2023-11-09 16:04     ` Sergey Bronnikov via Tarantool-patches
2023-11-23  6:31 ` Igor Munkin via Tarantool-patches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZV7xvB9MTFJCv8qj@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit] x86/x64: Fix math.ceil(-0.9) result sign.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox