view test/float_gcc.c @ 746:f8ea174944f2

i64 continue... global table have to be fixed.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 12 Nov 2010 22:19:55 +0900
parents efc99e397413
children c2c709727221
line wrap: on
line source

#include <math.h>

extern int printf(const char *,...);


#if 0
static __inline__ int __inline_signbitf( float __x ) {
    union{ float __f; unsigned int __u; 
    }
    __u = {__x};
    return (int)(__u.__u >> 31); 
}

static __inline__ int __inline_isnormalf( float __x ) {
    float fabsf = __builtin_fabsf(__x);
    if( __x != __x ) return 0;
    return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__;
}  

        extern double scalb ( double, double )  __asm("_scalb$UNIX2003" ); 
#endif


double fabs0(double a)
{
    return __builtin_fabs(a);
}

float fabsf0(float a)
{
    return __builtin_fabsf(a);
}



int main()
{
    float a = 0.3;
    double d = 0.3;
    float f ;
    double dd ;
    int i,j;
    i = __inline_signbitf(a);
    j = __inline_isnormalf(a);
    d = scalb( d, d );

    dd = __builtin_inf();
    printf("inf %g\n",dd);
    f = __builtin_inff();
    printf("inff %g\n",f);
    // printf("scalb %g\n",d);

    d = -0.3;

    printf("%d %d %g\n",i,j,d);
    printf("%g %g\n",fabs0(d),fabsf0(d));
    printf("%g %g\n",fabs0(-d),fabsf0(-d));
}