Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3afb84c

Browse files
committed
Remove another old rint() replacement.
1 parent0afe541 commit3afb84c

File tree

1 file changed

+1
-112
lines changed

1 file changed

+1
-112
lines changed

‎src/backend/utils/adt/float.c

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -83,14 +83,6 @@ static double cbrt(double x);
8383
externdoublecbrt(doublex);
8484
#endif
8585
#endif/* HAVE_CBRT */
86-
87-
#ifndefHAVE_RINT
88-
#definerint my_rint
89-
staticdoublerint(doublex);
90-
91-
#else
92-
externdoublerint(doublex);
93-
#endif/* HAVE_RINT */
9486
#endif/* NeXT check */
9587

9688

@@ -1937,109 +1929,6 @@ float84ge(PG_FUNCTION_ARGS)
19371929

19381930
/* ========== PRIVATE ROUTINES ========== */
19391931

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-
20431932
#ifndefHAVE_CBRT
20441933

20451934
staticdouble

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp