All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Jan Stancek <jstancek@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] nextafter01: Check exact results and convert to new API
Date: Mon, 19 Oct 2026 15:13:27 +0200	[thread overview]
Message-ID: <20261019131327.GA63027@pevik> (raw)
In-Reply-To: <89fe77f22e26d912865c8b8266b150ba7459bfae.1792413314.git.jstancek@redhat.com>

Hi Jan,

> The test can hardly fail. Block 1 accepts nextafter(1.0, 1.1) whenever
> (answer + 1.0) / 2 rounds to 1.0 as a float, which is also true when
> nextafter() returns 1.0 unchanged. Block 2 never recomputes 'check'
> and compares the stale value from block 1, which is exactly 1.0, so its
> 'check != 1.0' condition is always false and any return value passes.
> Only the x == y case in block 3 is really verified. The file header also
> names the test "scalb".

> Compare the results with the exact next doubles instead: 1.0 + 2^-52
> above and 1.0 - 2^-53 below. Both are exactly representable, so a plain
> equality test is sufficient. Rewrite the test with the new API while at
> it and fix the description.

Thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

...
> -char *TCID = "nextafter01";
> +static struct tcase {
> +	double x;
> +	double y;
> +	double exp;
> +} tcases[] = {
> +	{1.0, 1.1, 1.0 + EPSILON},
> +	{1.0, 0.9, 1.0 - EPSILON / 2},
> +	{1.0, 1.0, 1.0},
> +};

...
> +	if (ret == tc->exp) {
Hm, we still does not have TST_EXP_EQ_* variant for double.
Likely not worth of having it (not many tests comparing double).

Kind regards,
Petr

> +		tst_res(TPASS, "nextafter(%g, %g) == %.17g", tc->x, tc->y, ret);
> +	} else {
> +		tst_res(TFAIL, "nextafter(%g, %g) == %.17g, expected %.17g",
> +			tc->x, tc->y, ret, tc->exp);

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-10-19 13:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 12:35 [LTP] [PATCH] nextafter01: Check exact results and convert to new API Jan Stancek via ltp
2026-10-19 13:13 ` Petr Vorel [this message]
2026-10-20 10:03   ` Andrea Cervesato via ltp
2026-10-20 10:06     ` Petr Vorel
2026-10-19 19:05 ` [LTP] " linuxtestproject.agent
2026-10-19 21:08 ` [LTP] [PATCH] " Avinesh Kumar via ltp

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=20261019131327.GA63027@pevik \
    --to=pvorel@suse.cz \
    --cc=jstancek@redhat.com \
    --cc=ltp@lists.linux.it \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.