/*
* 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.
*/
#include "libm.h"
#if defined(__SUNPRO_C)
#include <sunmath.h> /* fabsl */
#endif
/* INDENT OFF */
static const int
/* INDENT ON */
#if defined(__sparc)
#define __H0(x) ((int *) &x)[0]
#else
#endif
/*
* On entrance: *quo is initialized to 0, x finite and y non-zero & ordered
*/
static long double
long double a, b;
int hx;
y0 &= ~0x80000000;
a = fabsl(x);
b = fabsl(y);
if (a <= b) {
if (a < b)
return (x);
else {
return (zero * x);
}
}
/* determine ix = ilogbl(x) */
ix = 0;
ix = -16382;
while (x0 == 0) {
ix -= 16;
}
ix -= 1;
x3 <<= 1;
}
} else {
}
/* determine iy = ilogbl(y) */
iy = -16382;
while (y0 == 0) {
iy -= 16;
}
iy -= 1;
y3 <<= 1;
}
} else {
}
/* fix point fmod */
m = 0;
while (n--) {
while (x0 == 0 && n >= 16) {
m <<= 16;
n -= 16;
}
m += m;
n -= 1;
}
carry = 0;
if (carry == 0) {
} else {
}
if (carry == 0) {
} else {
}
if (z0 < 0) { /* double x */
m += m;
} else {
m += 1;
if (z0 == 0) {
/* 0: we are done */
if (n < 31)
m <<= (1 + n);
else
m = 0;
m &= ~0x80000000;
return (a);
}
}
/* x = z << 1 */
m += m;
}
}
carry = 0;
if (carry == 0) {
} else {
}
if (carry == 0) {
} else {
}
if (z0 >= 0) {
m += 1;
}
m &= ~0x80000000;
/* convert back to floating value and restore the sign */
return (a);
}
if (x0 == 0) {
iy -= 16;
} else {
iy -= 1;
}
}
/* normalize output */
if (iy >= -16382) {
} else { /* subnormal output */
n = -16382 - iy;
k = n & 31;
if (k <= 16) {
x0 >>= k;
} else {
x0 = 0;
}
while (n >= 32) {
n -= 32;
x0 = 0;
}
a *= one;
}
return (a);
}
long double
long double v;
hy &= ~0x80000000;
/* purge off exception values */
*quo = 0;
/* y=0, y is NaN, x is NaN or inf */
return ((x * y) / (x * y));
y = fabsl(y);
x = fabsl(x);
if (hy <= 0x7ffdffff) {
}
if (hy < 0x00020000) {
if (x + x > y) {
*quo += 1;
if (x == y)
x = zero;
else
x -= y;
if (x + x >= y) {
x -= y;
*quo += 1;
}
}
} else {
v = 0.5L * y;
if (x > v) {
*quo += 1;
if (x == y)
x = zero;
else
x -= y;
if (x >= v) {
x -= y;
*quo += 1;
}
}
}
if (sq != 0)
return (sx == 0 ? x : -x);
}