rndintl.c revision 25c28e83beb90e7c80452a7c818c5e6f73a07dc8
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * CDDL HEADER START
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * The contents of this file are subject to the terms of the
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Common Development and Distribution License (the "License").
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * You may not use this file except in compliance with the License.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * See the License for the specific language governing permissions
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * and limitations under the License.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * When distributing Covered Code, include this CDDL HEADER in each
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * If applicable, add the following below this CDDL HEADER, with the
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * fields enclosed by brackets "[]" replaced with your own identifying
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * information: Portions Copyright [yyyy] [name of copyright owner]
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * CDDL HEADER END
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * Use is subject to license terms.
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * aintl(x) return x chopped to integral value
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * anintl(x) return sign(x)*(|x|+0.5) chopped to integral value
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * irintl(x) return rint(x) in integer format
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * nintl(x) return anint(x) in integer format
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result
c533a883a71cff9ff32df1c53c31201e1cbf371fhx * with the same sign as x's, including 0.0.
c533a883a71cff9ff32df1c53c31201e1cbf371fhxextern enum fp_direction_type __swapRD(enum fp_direction_type);
c533a883a71cff9ff32df1c53c31201e1cbf371fhxstatic const long double qone = 1.0L, qhalf = 0.5L, qmhalf = -0.5L;
c533a883a71cff9ff32df1c53c31201e1cbf371fhxlong double
c533a883a71cff9ff32df1c53c31201e1cbf371fhxaintl(long double x) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx long double t, w;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return (x + x);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx else /* |t|>|x| case */
c533a883a71cff9ff32df1c53c31201e1cbf371fhxlong double
c533a883a71cff9ff32df1c53c31201e1cbf371fhxanintl(long double x) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx long double t, w, z;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return (x + x);
c533a883a71cff9ff32df1c53c31201e1cbf371fhx if (t == w)
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return (copysignl(t, x));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx z = t - w;
c533a883a71cff9ff32df1c53c31201e1cbf371fhx else if (z <= qmhalf)
43439c96b8398c01c375889c79bed72d78fb4c39hx return (copysignl(t, x));
c533a883a71cff9ff32df1c53c31201e1cbf371fhxirintl(long double x) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx switch (rd) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return ((int)rintl(x));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return ((int)rintl(x));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return ((int)rintl(x));
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return ((int)rintl(x));
c533a883a71cff9ff32df1c53c31201e1cbf371fhxnintl(long double x) {
c533a883a71cff9ff32df1c53c31201e1cbf371fhx return ((int)anintl(x));