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/] [mathfp/] [ef_remainder.c] - Diff between revs 148 and 158

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

Rev 148 Rev 158
/* 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 remainderf(float x, float p)
        float remainderf(float x, float p)
#else
#else
        float remainderf(x,p)
        float 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(hp==0) return (x*p)/(x*p);            /* p = 0 */
        if(hp==0) return (x*p)/(x*p);            /* p = 0 */
        if((hx>=0x7f800000)||                   /* x not finite */
        if((hx>=0x7f800000)||                   /* x not finite */
          ((hp>0x7f800000)))                    /* p is NaN */
          ((hp>0x7f800000)))                    /* p is NaN */
            return (x*p)/(x*p);
            return (x*p)/(x*p);
 
 
 
 
        if (hp<=0x7effffff) x = fmodf(x,p+p);   /* now x < 2p */
        if (hp<=0x7effffff) x = 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.