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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libm/] [math/] [ef_remainder.c] - Diff between revs 207 and 345

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/* ef_remainder.c -- float version of e_remainder.c.
/* ef_remainder.c -- float version of e_remainder.c.
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
 */
 */
 
 
/*
/*
 * ====================================================
 * ====================================================
 * 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.
 * ====================================================
 * ====================================================
 */
 */
 
 
#include "fdlibm.h"
#include "fdlibm.h"
 
 
#ifdef __STDC__
#ifdef __STDC__
static const float zero = 0.0;
static const float zero = 0.0;
#else
#else
static float zero = 0.0;
static float zero = 0.0;
#endif
#endif
 
 
 
 
#ifdef __STDC__
#ifdef __STDC__
        float __ieee754_remainderf(float x, float p)
        float __ieee754_remainderf(float x, float p)
#else
#else
        float __ieee754_remainderf(x,p)
        float __ieee754_remainderf(x,p)
        float x,p;
        float x,p;
#endif
#endif
{
{
        __int32_t hx,hp;
        __int32_t hx,hp;
        __uint32_t sx;
        __uint32_t sx;
        float p_half;
        float p_half;
 
 
        GET_FLOAT_WORD(hx,x);
        GET_FLOAT_WORD(hx,x);
        GET_FLOAT_WORD(hp,p);
        GET_FLOAT_WORD(hp,p);
        sx = hx&0x80000000;
        sx = hx&0x80000000;
        hp &= 0x7fffffff;
        hp &= 0x7fffffff;
        hx &= 0x7fffffff;
        hx &= 0x7fffffff;
 
 
    /* purge off exception values */
    /* purge off exception values */
        if(FLT_UWORD_IS_ZERO(hp)||
        if(FLT_UWORD_IS_ZERO(hp)||
           !FLT_UWORD_IS_FINITE(hx)||
           !FLT_UWORD_IS_FINITE(hx)||
           FLT_UWORD_IS_NAN(hp))
           FLT_UWORD_IS_NAN(hp))
            return (x*p)/(x*p);
            return (x*p)/(x*p);
 
 
 
 
        if (hp<=FLT_UWORD_HALF_MAX) x = __ieee754_fmodf(x,p+p); /* now x < 2p */
        if (hp<=FLT_UWORD_HALF_MAX) x = __ieee754_fmodf(x,p+p); /* now x < 2p */
        if ((hx-hp)==0) return zero*x;
        if ((hx-hp)==0) return zero*x;
        x  = fabsf(x);
        x  = fabsf(x);
        p  = fabsf(p);
        p  = fabsf(p);
        if (hp<0x01000000) {
        if (hp<0x01000000) {
            if(x+x>p) {
            if(x+x>p) {
                x-=p;
                x-=p;
                if(x+x>=p) x -= p;
                if(x+x>=p) x -= p;
            }
            }
        } else {
        } else {
            p_half = (float)0.5*p;
            p_half = (float)0.5*p;
            if(x>p_half) {
            if(x>p_half) {
                x-=p;
                x-=p;
                if(x>=p_half) x -= p;
                if(x>=p_half) x -= p;
            }
            }
        }
        }
        GET_FLOAT_WORD(hx,x);
        GET_FLOAT_WORD(hx,x);
        SET_FLOAT_WORD(x,hx^sx);
        SET_FLOAT_WORD(x,hx^sx);
        return x;
        return x;
}
}
 
 

powered by: WebSVN 2.1.0

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