Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /* wf_fmod.c -- float version of w_fmod.c.
  2.  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
  3.  */
  4.  
  5. /*
  6.  * ====================================================
  7.  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  8.  *
  9.  * Developed at SunPro, a Sun Microsystems, Inc. business.
  10.  * Permission to use, copy, modify, and distribute this
  11.  * software is freely granted, provided that this notice
  12.  * is preserved.
  13.  * ====================================================
  14.  */
  15.  
  16. /*
  17.  * wrapper fmodf(x,y)
  18.  */
  19.  
  20. #include "fdlibm.h"
  21. #include <errno.h>
  22.  
  23. #ifdef __STDC__
  24.         float fmodf(float x, float y)   /* wrapper fmodf */
  25. #else
  26.         float fmodf(x,y)                /* wrapper fmodf */
  27.         float x,y;
  28. #endif
  29. {
  30. #ifdef _IEEE_LIBM
  31.         return __ieee754_fmodf(x,y);
  32. #else
  33.         float z;
  34.         struct exception exc;
  35.         z = __ieee754_fmodf(x,y);
  36.         if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
  37.         if(y==(float)0.0) {
  38.             /* fmodf(x,0) */
  39.             exc.type = DOMAIN;
  40.             exc.name = "fmodf";
  41.             exc.err = 0;
  42.             exc.arg1 = (double)x;
  43.             exc.arg2 = (double)y;
  44.             if (_LIB_VERSION == _SVID_)
  45.                exc.retval = x;
  46.             else
  47.                exc.retval = 0.0/0.0;
  48.             if (_LIB_VERSION == _POSIX_)
  49.                errno = EDOM;
  50.             else if (!matherr(&exc)) {
  51.                   errno = EDOM;
  52.             }
  53.             if (exc.err != 0)
  54.                errno = exc.err;
  55.             return (float)exc.retval;
  56.         } else
  57.             return z;
  58. #endif
  59. }
  60.  
  61. #ifdef _DOUBLE_IS_32BITS
  62.  
  63. #ifdef __STDC__
  64.         double fmod(double x, double y)
  65. #else
  66.         double fmod(x,y)
  67.         double x,y;
  68. #endif
  69. {
  70.         return (double) fmodf((float) x, (float) y);
  71. }
  72.  
  73. #endif /* defined(_DOUBLE_IS_32BITS) */
  74.