Ignore:
Timestamp:
Feb 4, 2016, 6:25:22 PM (8 years ago)
Author:
meunier
Message:
  • Ajout de quelques fonction dans la lib math
  • Déplacement de certaines fonctions de stdlib vers string
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_libs/math/e_pow.c

    r682 r777  
    103103        int32_t i,j,k,yisint,n;
    104104        int32_t hx,hy,ix,iy;
    105         u_int32_t lx,ly;
     105        uint32_t lx,ly;
    106106
    107107        EXTRACT_WORDS(hx,lx,x);
     
    180180
    181181    /* (x<0)**(non-int) is NaN */
    182         if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
     182        if(((((uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
    183183
    184184    /* |y| is huge */
     
    251251
    252252        s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
    253         if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0)
     253        if(((((uint32_t)hx>>31)-1)|(yisint-1))==0)
    254254            s = -one;/* (-ve)**(odd int) */
    255255
     
    312312{
    313313        double z = __ieee754_pow(x, y);
    314         if (isnan(y))
     314        if (isnan(y)) {
    315315                return z;
     316    }
    316317        if (isnan(x)) {
    317318                if (y == 0.0) {
     
    322323        if (x == 0.0) {
    323324                if (y == 0.0) {
    324                         return 0; /* pow(0.0,0.0) */
     325            return 0; /* pow(0.0,0.0) */
    325326                }
    326327                if (isfinite(y) && y < 0.0) {
     
    332333                if (isfinite(x) && isfinite(y)) {
    333334                        if (isnan(z)) {
    334                                 return 0.0/0.0; /* pow neg**non-int */
     335                                return 0.0 / 0.0; /* pow neg**non-int */
    335336                        }
    336337                        {
    337338                                double ret = huge;
    338339                                y *= 0.5;
    339                                 if(x<zero&&rint(y)!=y) ret = -huge;
     340                                if (x < zero && rint(y) !=y ) {
     341                    ret = -huge;
     342                }
    340343                                return ret;
    341344                        }
     
    347350        return z;
    348351}
     352
     353/*
     354 * Pseudo exp function (QM)
     355 * There probably is a better implementation
     356 */
     357double exp(double x)
     358{
     359    const double e = 2.71828182846;
     360    return pow(e, x);
     361}
     362
Note: See TracChangeset for help on using the changeset viewer.