delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/04/17/10:02:31

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21163389681B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1618668149;
bh=6QCgENfkA9vtchKc1PoRE6DMJWlagt+11S2aaxqhpnw=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=hszaJQA8AdpmRISfz3aQBPkebuhZV51ODhMEHEZEhZlBKvq9I5EGp6eFnKPXQ1Dv9
IvzLSaRGlXvxVG4pJPPdUmlufgHt18NV1acuXkrEhjtfp5YfXAGiThxcXY1AJ3Gyrf
oL/DbJJCc9YJRqqFR9YlB8HqZFR2GjIlCT889Qn8=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 498C93896817
X-Injected-Via-Gmane: http://gmane.org/
To: cygwin AT cygwin DOT com
Subject: hypotl(LDBL_MAX, 0.0L) = inf
Date: Sat, 17 Apr 2021 10:02:07 -0400
Message-ID: <vriuo8edqaao.fsf@mail.aol.com>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (cygwin)
Cancel-Lock: sha1:qGX99vfvw4WsBveCpqG2JtYVDl4=
X-Spam-Status: No, score=-2.5 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

Given that hypot(DBL_MAX, 0.0) = DBL_MAX and hypotf(FLT_MAX, 0.0f) =
FLT_MAX, I suspect this is a problem in hypotl.  Am I missing something?

There is a similar difference in cabsl compared to cabs and cabsf, which
probably has a similar cause.

I attached my test case, which I compile with
gcc -Og -O0 test_cabs_hypot.c -o test_cabs_hypot

What should I expect here?


--=-=-=
Content-Type: text/x-csrc
Content-Disposition: attachment; filename=test_cabs_hypot.c
Content-Description: STC showing behavior of hypotl compared to hypot and hypotf

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

int main(void) {
  _Complex long double test_cabsl = LDBL_MAX + 0.0L * _Complex_I;
  long double test_hypotl1 = LDBL_MAX, test_hypotl2 = 0.0L;
  _Complex double test_cabs = DBL_MAX + 0.0L * _Complex_I;
  double test_hypot1 = DBL_MAX, test_hypot2 = 0.0L;
  _Complex float test_cabsf = FLT_MAX + 0.0L * _Complex_I;
  float test_hypotf1 = FLT_MAX, test_hypotf2 = 0.0L;

  printf("cabsl(%Lg%+Lgi) = %Lg\n", creall(test_cabsl), cimagl(test_cabsl), cabsl(test_cabsl));
  printf("hypotl(%Lg, %Lg) = %Lg\n\n", test_hypotl1, test_hypotl2, hypotl(test_hypotl1, test_hypotl2));

  printf("cabs(%lg%+lgi) = %lg\n", creal(test_cabs), cimag(test_cabs), cabs(test_cabs));
  printf("hypot(%lg, %lg) = %lg\n\n", test_hypot1, test_hypot2, hypot(test_hypot1, test_hypot2));

  printf("cabsf(%g%+gi) = %g\n", crealf(test_cabsf), cimagf(test_cabsf), cabsf(test_cabsf));
  printf("hypotf(%g, %g) = %g\n\n", test_hypotf1, test_hypotf2, hypotf(test_hypotf1, test_hypotf2));
  return 0;
}

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