OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libm/] [math/] [w_fmod.c] - Diff between revs 148 and 158

Only display areas with differences | Details | Blame | View Log

Rev 148 Rev 158
 
 
/* @(#)w_fmod.c 5.1 93/09/24 */
/* @(#)w_fmod.c 5.1 93/09/24 */
/*
/*
 * ====================================================
 * ====================================================
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 *
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * software is freely granted, provided that this notice
 * is preserved.
 * is preserved.
 * ====================================================
 * ====================================================
 */
 */
 
 
/*
/*
FUNCTION
FUNCTION
<<fmod>>, <<fmodf>>---floating-point remainder (modulo)
<<fmod>>, <<fmodf>>---floating-point remainder (modulo)
 
 
INDEX
INDEX
fmod
fmod
INDEX
INDEX
fmodf
fmodf
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
#include <math.h>
#include <math.h>
double fmod(double <[x]>, double <[y]>)
double fmod(double <[x]>, double <[y]>)
float fmodf(float <[x]>, float <[y]>)
float fmodf(float <[x]>, float <[y]>)
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
#include <math.h>
#include <math.h>
double fmod(<[x]>, <[y]>)
double fmod(<[x]>, <[y]>)
double (<[x]>, <[y]>);
double (<[x]>, <[y]>);
 
 
float fmodf(<[x]>, <[y]>)
float fmodf(<[x]>, <[y]>)
float (<[x]>, <[y]>);
float (<[x]>, <[y]>);
 
 
DESCRIPTION
DESCRIPTION
The <<fmod>> and <<fmodf>> functions compute the floating-point
The <<fmod>> and <<fmodf>> functions compute the floating-point
remainder of <[x]>/<[y]> (<[x]> modulo <[y]>).
remainder of <[x]>/<[y]> (<[x]> modulo <[y]>).
 
 
RETURNS
RETURNS
The <<fmod>> function returns the value
The <<fmod>> function returns the value
@ifnottex
@ifnottex
<[x]>-<[i]>*<[y]>,
<[x]>-<[i]>*<[y]>,
@end ifnottex
@end ifnottex
@tex
@tex
$x-i\times y$,
$x-i\times y$,
@end tex
@end tex
for the largest integer <[i]> such that, if <[y]> is nonzero, the
for the largest integer <[i]> such that, if <[y]> is nonzero, the
result has the same sign as <[x]> and magnitude less than the
result has the same sign as <[x]> and magnitude less than the
magnitude of <[y]>.
magnitude of <[y]>.
 
 
<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>.
<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>.
 
 
You can modify error treatment for these functions using <<matherr>>.
You can modify error treatment for these functions using <<matherr>>.
 
 
PORTABILITY
PORTABILITY
<<fmod>> is ANSI C. <<fmodf>> is an extension.
<<fmod>> is ANSI C. <<fmodf>> is an extension.
*/
*/
 
 
/*
/*
 * wrapper fmod(x,y)
 * wrapper fmod(x,y)
 */
 */
 
 
#include "fdlibm.h"
#include "fdlibm.h"
#include <errno.h>
#include <errno.h>
 
 
#ifndef _DOUBLE_IS_32BITS
#ifndef _DOUBLE_IS_32BITS
 
 
#ifdef __STDC__
#ifdef __STDC__
        double fmod(double x, double y) /* wrapper fmod */
        double fmod(double x, double y) /* wrapper fmod */
#else
#else
        double fmod(x,y)                /* wrapper fmod */
        double fmod(x,y)                /* wrapper fmod */
        double x,y;
        double x,y;
#endif
#endif
{
{
#ifdef _IEEE_LIBM
#ifdef _IEEE_LIBM
        return __ieee754_fmod(x,y);
        return __ieee754_fmod(x,y);
#else
#else
        double z;
        double z;
        struct exception exc;
        struct exception exc;
        z = __ieee754_fmod(x,y);
        z = __ieee754_fmod(x,y);
        if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
        if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
        if(y==0.0) {
        if(y==0.0) {
            /* fmod(x,0) */
            /* fmod(x,0) */
            exc.type = DOMAIN;
            exc.type = DOMAIN;
            exc.name = "fmod";
            exc.name = "fmod";
            exc.arg1 = x;
            exc.arg1 = x;
            exc.arg2 = y;
            exc.arg2 = y;
            exc.err = 0;
            exc.err = 0;
            if (_LIB_VERSION == _SVID_)
            if (_LIB_VERSION == _SVID_)
               exc.retval = x;
               exc.retval = x;
            else
            else
               exc.retval = 0.0/0.0;
               exc.retval = 0.0/0.0;
            if (_LIB_VERSION == _POSIX_)
            if (_LIB_VERSION == _POSIX_)
               errno = EDOM;
               errno = EDOM;
            else if (!matherr(&exc)) {
            else if (!matherr(&exc)) {
                  errno = EDOM;
                  errno = EDOM;
            }
            }
            if (exc.err != 0)
            if (exc.err != 0)
               errno = exc.err;
               errno = exc.err;
            return exc.retval;
            return exc.retval;
        } else
        } else
            return z;
            return z;
#endif
#endif
}
}
 
 
#endif /* defined(_DOUBLE_IS_32BITS) */
#endif /* defined(_DOUBLE_IS_32BITS) */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.