From owner-freebsd-standards@FreeBSD.ORG Sun Jun 26 17:10:19 2005 Return-Path: X-Original-To: freebsd-standards@hub.freebsd.org Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1586216A43E for ; Sun, 26 Jun 2005 17:10:19 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E4A1043D48 for ; Sun, 26 Jun 2005 17:10:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j5QHAIda081677 for ; Sun, 26 Jun 2005 17:10:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j5QHAID6081676; Sun, 26 Jun 2005 17:10:18 GMT (envelope-from gnats) Date: Sun, 26 Jun 2005 17:10:18 GMT Message-Id: <200506261710.j5QHAID6081676@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: "Steven G. Kargl" Cc: Subject: Re: standards/82654: C99 long double math functions are missing X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Steven G. Kargl" List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jun 2005 17:10:19 -0000 The following reply was made to PR standards/82654; it has been noted by GNATS. From: "Steven G. Kargl" To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-standards@FreeBSD.org Cc: Subject: Re: standards/82654: C99 long double math functions are missing Date: Sun, 26 Jun 2005 10:00:57 -0700 (PDT) --ELM1119805257-98328-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII FreeBSD-gnats-submit@FreeBSD.org wrote: > >Category: standards > >Responsible: freebsd-standards > >Synopsis: C99 long double math functions are missing > >Arrival-Date: Sat Jun 25 23:40:12 GMT 2005 > The attached files implement hypotl() and cabsl(). The documentation has been updated. Note hypot(3) manpage refers to a non-existent cabs.c file. -- Steve http://troutmask.apl.washington.edu/~kargl/ --ELM1119805257-98328-0_ Content-Transfer-Encoding: 7bit Content-Type: text/x-c++src Content-Disposition: attachment; filename=hypotl.c Content-Description: /*- * Copyright (c) 2005, Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice unmodified, this list of conditions, and the following * disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Compute the hypot(x,y) = sqrt(x*x+y*y) for long double x and y. */ #include long double sqrtl(long double); static long double zero = 0.0L; long double hypotl(long double x, long double y) { long double ax, ay; /* If x or y is a +-Inf, return +Inf. */ if (isinf(x) || isinf(y)) return (-1.L / zero); /* If x or y is a NaN, return NaN. */ if (isnan(x) || isnan(y)) return (x*x+x) + (y*y+y); ax = fabsl(x); ay = fabsl(y); /* Special case if x and/or y is zero. */ if (ax == zero || ay == zero) return (ay + ax); /* Avoid overflow in sqrtl(x*x + y*y) */ if (ax >= ay) { ay /= ax; ax = ax * sqrtl(1.0L + ay * ay); } else { ax /= ay; ax = ay * sqrtl(ax * ax + 1.0L); } return ax; } --ELM1119805257-98328-0_ Content-Transfer-Encoding: 7bit Content-Type: text/x-c++src Content-Disposition: attachment; filename=cabsl.c Content-Description: /*- * Copyright (c) 2005, Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice unmodified, this list of conditions, and the following * disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Compute the absolute value of a long double complex argument via a * call to hypotl(). */ #include #include long double cabsl(long double complex z) { return hypotl(creall(z), cimagl(z)); } --ELM1119805257-98328-0_ Content-Transfer-Encoding: 7bit Content-Type: text/x-patch Content-Disposition: attachment; filename=hypot.3.diff Content-Description: --- hypot.3.orig Sun Jun 26 09:46:01 2005 +++ hypot.3 Sun Jun 26 09:53:20 2005 @@ -38,8 +38,10 @@ .Sh NAME .Nm hypot , .Nm hypotf , +.Nm hypotl , .Nm cabs , -.Nm cabsf +.Nm cabsf , +.Nm cabsl .Nd Euclidean distance and complex absolute value functions .Sh LIBRARY .Lb libm @@ -49,25 +51,31 @@ .Fn hypot "double x" "double y" .Ft float .Fn hypotf "float x" "float y" +.Ft "long double" +.Fn hypotl "long double x" "long double y" .In complex.h .Ft double .Fn cabs "double complex z" .Ft float .Fn cabsf "float complex z" +.Ft "long double" +.Fn cabsl "long double complex z" .Sh DESCRIPTION The -.Fn hypot +.Fn hypot , +.Fn hypotf , and -.Fn hypotf +.Fn hypotl functions compute the sqrt(x*x+y*y) in such a way that underflow will not happen, and overflow occurs only if the final result deserves it. The -.Fn cabs +.Fn cabs , +.Fn cabsf , and -.Fn cabsf +.Fn cabsl functions compute the complex absolute value of .Fa z . .Pp --ELM1119805257-98328-0_--