delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/10/27/07:18:01

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9B783950C6A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1603797436;
bh=j5IHd2gFBJcS/d4+EymvqHts2NBeq6Nu/DtVplhkh3k=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=Rch/HqRWDx8ungB364nCAMmRWCjl/XDnjvTZDC2ssD3xnvFFKQQrCHGSWN1fjPVzy
+5AeC4OfPjlSCrEHNNovCmHHi9LFKCnefuB3F7Zbl9NGsYgDpQG/TOj+EWsw9s8yWs
2iS288wv+Wce9Nz6P85OVxoKCGn2LkM/fbtuGVc4=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E51363950C78
X-Injected-Via-Gmane: http://gmane.org/
To: cygwin AT cygwin DOT com
Subject: sqrtl behavior inconsistent with sqrt and sqrtf
Date: Tue, 27 Oct 2020 07:17:01 -0400
Message-ID: <vriulffr2a1e.fsf@mail.aol.com>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (cygwin)
Cancel-Lock: sha1:iwO1Yxk6HWD9d/M9qDZ/w9J9obo=
X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,
FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,
KAM_DMARC_STATUS, KAM_GOODAOL, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: airplanemath via Cygwin <cygwin AT cygwin DOT com>
Reply-To: airplanemath <airplanemath AT aol DOT com>
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

--=-=-=
Content-Type: text/plain

Compiling and running the attached program with the command line below
produces the output below:

--=-=-=
Content-Type: text/plain
Content-Disposition: inline; filename=test_sqrt.c
Content-Description: Test program for sqrtl, sqrt, and sqrtf

#include <math.h>
#include <stdio.h>

int main() {
  long double a, b;
  double c, d;
  float f, g;
  a = (long double) -INFINITY;
  c = (double) -INFINITY;
  f = (float) -INFINITY;
  b = sqrtl(a);
  d = sqrt(c);
  g = sqrtf(f);
  printf("Long double: %4Lf %4Lf\n", a, b);
  printf("Double:      %4lf %4lf\n", c, d);
  printf("Float:       %4f %4f\n", f, g);
  return 0;
}

--=-=-=
Content-Type: text/plain


$ gcc -O0 -Og test_sqrt.c -o test_sqrt && ./test_sqrt
Long double: -inf -inf
Double:      -inf -nan
Float:       -inf -nan

I suspect the behavior for long double should be the same as for double
and float (sqrt(-inf) = nan), but I'm not sure where to change that.
I'm running a snapshot of Cygwin 3.2.0, if that's important.

--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

--=-=-=--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019