]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Math/e_fmod.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / LibC / Math / e_fmod.c
diff --git a/StdLib/LibC/Math/e_fmod.c b/StdLib/LibC/Math/e_fmod.c
deleted file mode 100644 (file)
index 3cb06c1..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/* @(#)e_fmod.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: e_fmod.c,v 1.11 2002/05/26 22:01:49 wiz Exp $");\r
-#endif\r
-\r
-/*\r
- * __ieee754_fmod(x,y)\r
- * Return x mod y in exact arithmetic\r
- * Method: shift and subtract\r
- */\r
-\r
-#include "math.h"\r
-#include "math_private.h"\r
-\r
-#if defined(_MSC_VER)           /* Handle Microsoft VC++ compiler specifics. */\r
-  // unary minus operator applied to unsigned type, result still unsigned\r
-  #pragma warning ( disable : 4146 )\r
-#endif\r
-\r
-static const double one = 1.0, Zero[] = {0.0, -0.0,};\r
-\r
-double\r
-__ieee754_fmod(double x, double y)\r
-{\r
-  int32_t n,hx,hy,hz,ix,iy,sx,i;\r
-  u_int32_t lx,ly,lz;\r
-\r
-  EXTRACT_WORDS(hx,lx,x);\r
-  EXTRACT_WORDS(hy,ly,y);\r
-  sx = hx&0x80000000;   /* sign of x */\r
-  hx ^=sx;    /* |x| */\r
-  hy &= 0x7fffffff; /* |y| */\r
-\r
-    /* purge off exception values */\r
-  if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */\r
-    ((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */\r
-      return (x*y)/(x*y);\r
-  if(hx<=hy) {\r
-      if((hx<hy)||(lx<ly)) return x;  /* |x|<|y| return x */\r
-      if(lx==ly)\r
-    return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/\r
-  }\r
-\r
-    /* determine ix = ilogb(x) */\r
-  if(hx<0x00100000) { /* subnormal x */\r
-      if(hx==0) {\r
-    for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;\r
-      } else {\r
-    for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;\r
-      }\r
-  } else ix = (hx>>20)-1023;\r
-\r
-    /* determine iy = ilogb(y) */\r
-  if(hy<0x00100000) { /* subnormal y */\r
-      if(hy==0) {\r
-    for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;\r
-      } else {\r
-    for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;\r
-      }\r
-  } else iy = (hy>>20)-1023;\r
-\r
-    /* set up {hx,lx}, {hy,ly} and align y to x */\r
-  if(ix >= -1022)\r
-      hx = 0x00100000|(0x000fffff&hx);\r
-  else {    /* subnormal x, shift x to normal */\r
-      n = -1022-ix;\r
-      if(n<=31) {\r
-          hx = (hx<<n)|(lx>>(32-n));\r
-          lx <<= n;\r
-      } else {\r
-    hx = lx<<(n-32);\r
-    lx = 0;\r
-      }\r
-  }\r
-  if(iy >= -1022)\r
-      hy = 0x00100000|(0x000fffff&hy);\r
-  else {    /* subnormal y, shift y to normal */\r
-      n = -1022-iy;\r
-      if(n<=31) {\r
-          hy = (hy<<n)|(ly>>(32-n));\r
-          ly <<= n;\r
-      } else {\r
-    hy = ly<<(n-32);\r
-    ly = 0;\r
-      }\r
-  }\r
-\r
-    /* fix point fmod */\r
-  n = ix - iy;\r
-  while(n--) {\r
-      hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;\r
-      if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}\r
-      else {\r
-        if((hz|lz)==0)    /* return sign(x)*0 */\r
-        return Zero[(u_int32_t)sx>>31];\r
-        hx = hz+hz+(lz>>31); lx = lz+lz;\r
-      }\r
-  }\r
-  hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;\r
-  if(hz>=0) {hx=hz;lx=lz;}\r
-\r
-    /* convert back to floating value and restore the sign */\r
-  if((hx|lx)==0)      /* return sign(x)*0 */\r
-      return Zero[(u_int32_t)sx>>31];\r
-  while(hx<0x00100000) {    /* normalize x */\r
-      hx = hx+hx+(lx>>31); lx = lx+lx;\r
-      iy -= 1;\r
-  }\r
-  if(iy>= -1022) {  /* normalize output */\r
-      hx = ((hx-0x00100000)|((iy+1023)<<20));\r
-      INSERT_WORDS(x,hx|sx,lx);\r
-  } else {    /* subnormal output */\r
-      n = -1022 - iy;\r
-      if(n<=20) {\r
-    lx = (lx>>n)|((u_int32_t)hx<<(32-n));\r
-    hx >>= n;\r
-      } else if (n<=31) {\r
-    lx = (hx<<(32-n))|(lx>>n); hx = sx;\r
-      } else {\r
-    lx = hx>>(n-32); hx = sx;\r
-      }\r
-      INSERT_WORDS(x,hx|sx,lx);\r
-      x *= one;   /* create necessary signal */\r
-  }\r
-  return x;   /* exact output */\r
-}\r