/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* hypotl(x,y)
* Method :
* If z=x*x+y*y has error less than sqrt(2)/2 ulp than sqrt(z) has
* error less than 1 ulp.
* So, compute sqrt(x*x+y*y) with some care as follows:
* Assume x>y>0;
* 1. save and set rounding to round-to-nearest
* 2. if x > 2y use
* x1*x1+(y*y+(x2*(x+x2))) for x*x+y*y
* where x1 = x with lower 32 bits cleared, x2 = x-x1; else
* 3. if x <= 2y use
* t1*y1+((x-y)*(x-y)+(t1*y2+t2*y))
* where t1 = 2x with lower 64 bits cleared, t2 = 2x-t1, y1= y with
* lower 32 bits cleared, y2 = y-y1.
*
* NOTE: DO NOT remove parenthsis!
*
* Special cases:
* hypot(x,y) is INF if x or y is +INF or -INF; else
* hypot(x,y) is NAN if x or y is NAN.
*
* Accuracy:
* hypot(x,y) returns sqrt(x^2+y^2) with error less than 1 ulps (units
* in the last place)
*/
#include "libm.h"
#if defined(__x86)
#define k 0x7fff
long double
hypotl(long double x, long double y) {
w = x;
x = y;
y = w;
} /* force nx >= ny */
return (x + y); /* x / y >= 2**65 */
/* save and set RD to Rounding to nearest */
w = x - y;
if (w > y) {
pt1[0] = 0;
} else {
x += x;
py1[0] = 0;
pt1[0] = 0;
}
if (rd != fp_nearest)
return (x);
} else {
/* since nx >= ny; nx is always k within this block */
return (x);
return (y);
else
return (x + y);
}
if (ny == 0) {
if (y == 0.L || x == 0.L)
return (x + y);
pt1[0] = 0;
py1[0] = 0;
x *= t1;
y *= t1;
}
j = nx - 0x3fff;
px[2] -= j;
py[2] -= j;
pt1[0] = 0;
}
}
#endif