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

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA4433951832
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1603799083;
bh=uUmXowEz7OwfQ4HlDZgm531jrmzQLzMcnRistShgd2g=;
h=To:Subject:Date:References:List-Id:List-Unsubscribe:List-Archive:
List-Post:List-Help:List-Subscribe:From:Reply-To:From;
b=rp7ELZc4Xp2pP3bXWpq8U1Fn12u/vI8NlL7kgiJZQCRwg0V64AJpr/q3cQtNC7f23
eFO7TAhMd55VhNaDeDTBQzT6zzM2PTj82PCeOzuC53IWJBiCWYoCS6jEAxjegQ30ot
FlSYRgttUwQ+t2fCR0OiBP14wW7+PlM1Twp82GVM=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D9163951840
X-Injected-Via-Gmane: http://gmane.org/
To: cygwin AT cygwin DOT com
Subject: Re: sqrtl behavior inconsistent with sqrt and sqrtf
Date: Tue, 27 Oct 2020 07:44:32 -0400
Message-ID: <vriuh7qf28rj.fsf@mail.aol.com>
References: <vriulffr2a1e DOT fsf AT mail DOT aol DOT com>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (cygwin)
Cancel-Lock: sha1:6De5zZEQer7fcV1F/onMPDfsOO4=
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>

airplanemath via Cygwin <cygwin AT cygwin DOT com> writes:

> Compiling and running the attached program with the command line below
> produces the output below:
>
> $ 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.

The mail archive says I'm bad at attaching things.
Program source included below:

#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;
}

--
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