|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.85 2003/04/21 00:22:24tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.86 2003/05/09 16:31:24momjian Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -83,14 +83,6 @@ static double cbrt(double x);
|
83 | 83 | externdoublecbrt(doublex);
|
84 | 84 | #endif
|
85 | 85 | #endif/* HAVE_CBRT */
|
86 |
| - |
87 |
| -#ifndefHAVE_RINT |
88 |
| -#definerint my_rint |
89 |
| -staticdoublerint(doublex); |
90 |
| - |
91 |
| -#else |
92 |
| -externdoublerint(doublex); |
93 |
| -#endif/* HAVE_RINT */ |
94 | 86 | #endif/* NeXT check */
|
95 | 87 |
|
96 | 88 |
|
@@ -1937,109 +1929,6 @@ float84ge(PG_FUNCTION_ARGS)
|
1937 | 1929 |
|
1938 | 1930 | /* ========== PRIVATE ROUTINES ========== */
|
1939 | 1931 |
|
1940 |
| -/* From "fdlibm" @ netlib.att.com */ |
1941 |
| - |
1942 |
| -#ifndefHAVE_RINT |
1943 |
| - |
1944 |
| -/* @(#)s_rint.c 5.1 93/09/24 */ |
1945 |
| -/* |
1946 |
| - * ==================================================== |
1947 |
| - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
1948 |
| - * |
1949 |
| - * Developed at SunPro, a Sun Microsystems, Inc. business. |
1950 |
| - * Permission to use, copy, modify, and distribute this |
1951 |
| - * software is freely granted, provided that this notice |
1952 |
| - * is preserved. |
1953 |
| - * ==================================================== |
1954 |
| - */ |
1955 |
| - |
1956 |
| -/* |
1957 |
| - * rint(x) |
1958 |
| - * Return x rounded to integral value according to the prevailing |
1959 |
| - * rounding mode. |
1960 |
| - * Method: |
1961 |
| - *Using floating addition. |
1962 |
| - * Exception: |
1963 |
| - *Inexact flag raised if x not equal to rint(x). |
1964 |
| - */ |
1965 |
| - |
1966 |
| -staticconstdoubleone=1.0, |
1967 |
| -TWO52[2]= { |
1968 |
| -4.50359962737049600000e+15,/* 0x43300000, 0x00000000 */ |
1969 |
| --4.50359962737049600000e+15,/* 0xC3300000, 0x00000000 */ |
1970 |
| -}; |
1971 |
| - |
1972 |
| -staticdouble |
1973 |
| -rint(doublex) |
1974 |
| -{ |
1975 |
| -inti0, |
1976 |
| -n0, |
1977 |
| -j0, |
1978 |
| -sx; |
1979 |
| -unsignedi, |
1980 |
| -i1; |
1981 |
| -doublew, |
1982 |
| -t; |
1983 |
| - |
1984 |
| -n0= (*((int*)&one) >>29) ^1; |
1985 |
| -i0=*(n0+ (int*)&x); |
1986 |
| -sx= (i0 >>31)&1; |
1987 |
| -i1=*(1-n0+ (int*)&x); |
1988 |
| -j0= ((i0 >>20)&0x7ff)-0x3ff; |
1989 |
| -if (j0<20) |
1990 |
| -{ |
1991 |
| -if (j0<0) |
1992 |
| -{ |
1993 |
| -if (((i0&0x7fffffff) |i1)==0) |
1994 |
| -returnx; |
1995 |
| -i1 |= (i0&0x0fffff); |
1996 |
| -i0 &=0xfffe0000; |
1997 |
| -i0 |= ((i1 |-i1) >>12)&0x80000; |
1998 |
| -*(n0+ (int*)&x)=i0; |
1999 |
| -w=TWO52[sx]+x; |
2000 |
| -t=w-TWO52[sx]; |
2001 |
| -i0=*(n0+ (int*)&t); |
2002 |
| -*(n0+ (int*)&t)= (i0&0x7fffffff) | (sx <<31); |
2003 |
| -returnt; |
2004 |
| -} |
2005 |
| -else |
2006 |
| -{ |
2007 |
| -i= (0x000fffff) >>j0; |
2008 |
| -if (((i0&i) |i1)==0) |
2009 |
| -returnx;/* x is integral */ |
2010 |
| -i >>=1; |
2011 |
| -if (((i0&i) |i1)!=0) |
2012 |
| -{ |
2013 |
| -if (j0==19) |
2014 |
| -i1=0x40000000; |
2015 |
| -else |
2016 |
| -i0= (i0& (~i)) | ((0x20000) >>j0); |
2017 |
| -} |
2018 |
| -} |
2019 |
| -} |
2020 |
| -elseif (j0>51) |
2021 |
| -{ |
2022 |
| -if (j0==0x400) |
2023 |
| -returnx+x;/* inf or NaN */ |
2024 |
| -else |
2025 |
| -returnx;/* x is integral */ |
2026 |
| -} |
2027 |
| -else |
2028 |
| -{ |
2029 |
| -i= ((unsigned) (0xffffffff)) >> (j0-20); |
2030 |
| -if ((i1&i)==0) |
2031 |
| -returnx;/* x is integral */ |
2032 |
| -i >>=1; |
2033 |
| -if ((i1&i)!=0) |
2034 |
| -i1= (i1& (~i)) | ((0x40000000) >> (j0-20)); |
2035 |
| -} |
2036 |
| -*(n0+ (int*)&x)=i0; |
2037 |
| -*(1-n0+ (int*)&x)=i1; |
2038 |
| -w=TWO52[sx]+x; |
2039 |
| -returnw-TWO52[sx]; |
2040 |
| -} |
2041 |
| -#endif/* !HAVE_RINT */ |
2042 |
| - |
2043 | 1932 | #ifndefHAVE_CBRT
|
2044 | 1933 |
|
2045 | 1934 | staticdouble
|
|