/*
* 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.
*/
/* INDENT OFF */
/*
* double remquo(double x, double y, int *quo) return remainder(x,y) and an
* integer pointer quo such that *quo = N mod {2**31}, where N is the
* exact integral part of x/y rounded to nearest even.
*
* remquo call internal fmodquo
*/
/* INDENT ON */
#include "libm.h"
#include "libm_protos.h"
#include <math.h> /* fabs() */
#include <sys/isa_defs.h>
#if defined(_BIG_ENDIAN)
#define HIWORD 0
#else
#define LOWORD 0
#endif
static double
/* purge off exception values */
*quo = 0;
return ((x * y) / (x * y));
return (x); /* |x|<|y| return x */
/* |x|=|y| return x*0 */
}
}
/* determine ix = ilogb(x) */
if (hx == 0) {
ix -= 1;
} else {
ix -= 1;
}
} else
/* determine iy = ilogb(y) */
if (hy == 0) {
iy -= 1;
} else {
iy -= 1;
}
} else
/* set up {hx,lx}, {hy,ly} and align y to x */
if (ix >= -1022)
else { /* subnormal x, shift x to normal */
n = -1022 - ix;
if (n <= 31) {
lx <<= n;
} else {
lx = 0;
}
}
if (iy >= -1022)
else { /* subnormal y, shift y to normal */
n = -1022 - iy;
if (n <= 31) {
ly <<= n;
} else {
ly = 0;
}
}
/* fix point fmod */
m = 0;
while (n--) {
hz -= 1;
if (hz < 0) {
} else {
m += 1;
if (n < 31)
m <<= 1 + n;
else
m = 0;
m &= 0x7fffffff;
}
}
m += m;
}
hz -= 1;
if (hz >= 0) {
m += 1;
}
m &= 0x7fffffff;
/* convert back to floating value and restore the sign */
}
iy -= 1;
}
} else { /* subnormal output */
n = -1022 - iy;
if (n <= 20) {
hx >>= n;
} else if (n <= 31) {
} else {
}
x *= one; /* create necessary signal */
}
return (x); /* exact output */
}
double
double v;
unsigned ly;
/* purge off exception values */
*quo = 0;
return ((x * y) / (x * y));
y = fabs(y);
x = fabs(x);
if (hy <= 0x7fdfffff) {
}
if (hy < 0x00200000) {
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.5 * 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);
}