+++ /dev/null
-/* @(#)s_ceil.c 5.1 93/09/24 */\r
-/*\r
- * ====================================================\r
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\r
- *\r
- * Developed at SunPro, a Sun Microsystems, Inc. business.\r
- * Permission to use, copy, modify, and distribute this\r
- * software is freely granted, provided that this notice\r
- * is preserved.\r
- * ====================================================\r
- */\r
-#include <LibConfig.h>\r
-#include <sys/EfiCdefs.h>\r
-#if defined(LIBM_SCCS) && !defined(lint)\r
-__RCSID("$NetBSD: s_ceil.c,v 1.11 2002/05/26 22:01:54 wiz Exp $");\r
-#endif\r
-\r
-/*\r
- * ceil(x)\r
- * Return x rounded toward -inf to integral value\r
- * Method:\r
- * Bit twiddling.\r
- * Exception:\r
- * Inexact flag raised if x not equal to ceil(x).\r
- */\r
-\r
-#include "math.h"\r
-#include "math_private.h"\r
-\r
-static const double huge = 1.0e300;\r
-\r
-double\r
-ceil(double x)\r
-{\r
- int32_t i0,i1,j0;\r
- u_int32_t i,j;\r
-\r
- EXTRACT_WORDS(i0,i1,x);\r
- j0 = ((i0>>20)&0x7ff)-0x3ff;\r
- if(j0<20) {\r
- if(j0<0) { /* raise inexact if x != 0 */\r
- if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */\r
- if(i0<0) {i0=0x80000000;i1=0;}\r
- else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}\r
- }\r
- } else {\r
- i = (0x000fffff)>>j0;\r
- if(((i0&i)|i1)==0) return x; /* x is integral */\r
- if(huge+x>0.0) { /* raise inexact flag */\r
- if(i0>0) i0 += (0x00100000)>>j0;\r
- i0 &= (~i); i1=0;\r
- }\r
- }\r
- } else if (j0>51) {\r
- if(j0==0x400) return x+x; /* inf or NaN */\r
- else return x; /* x is integral */\r
- } else {\r
- i = ((u_int32_t)(0xffffffff))>>(j0-20);\r
- if((i1&i)==0) return x; /* x is integral */\r
- if(huge+x>0.0) { /* raise inexact flag */\r
- if(i0>0) {\r
- if(j0==20) i0+=1;\r
- else {\r
- j = i1 + (1<<(52-j0));\r
- if((int32_t)j<i1) i0+=1; /* got a carry */\r
- i1 = j;\r
- }\r
- }\r
- i1 &= (~i);\r
- }\r
- }\r
- INSERT_WORDS(x,i0,i1);\r
- return x;\r
-}\r