public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2 4/9] math: Use an improved algorithm for hypot (dbl-64)
Date: Fri, 29 Oct 2021 16:20:07 +0000	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2110291612580.1788146@digraph.polyomino.org.uk> (raw)
In-Reply-To: <VE1PR08MB5599913805E2904931AA711483879@VE1PR08MB5599.eurprd08.prod.outlook.com>

On Fri, 29 Oct 2021, Wilco Dijkstra via Libc-alpha wrote:

> Hi Joseph,
> 
> > Scaling down doesn't set the underflow flag if the scaling down was exact 
> > (even though the actual hypot operation is inexact and so should raise 
> > underflow).
> 
> That's true, but doesn't that apply to the float version too? The convert from
> double to float might also be precise (and denormal) even if earlier calculations
> were inexact.

The only case where hypotf can have a mathematical result that is tiny and 
inexact is when both arguments are in the subnormal range for float and 
the implementation in terms of double then involves computing the (double) 
square root of a number M * 2^-298, for some (exact) M in the range [2, 
2^46), and then converting that (double) square root to float.

The square root of an integer in the range [2, 2^46) cannot be close 
enough to an integer for the result of rounding it in either direction to 
53 bits (so at least 30 fractional bits) to be an integer, so it is not 
possible for the conversion from double to float to be exact when the 
mathematical result of hypotf is tiny and inexact.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2021-10-29 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 15:19 Wilco Dijkstra
2021-10-28 17:19 ` Joseph Myers
2021-10-29 12:38   ` Wilco Dijkstra
2021-10-29 16:20     ` Joseph Myers [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-25 11:57 [PATCH v2 0/9] Improve hypot() Adhemerval Zanella
2021-10-25 11:57 ` [PATCH v2 4/9] math: Use an improved algorithm for hypot (dbl-64) Adhemerval Zanella

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=alpine.DEB.2.22.394.2110291612580.1788146@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=libc-alpha@sourceware.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).