Mercurial > hg > CbC > old > device
changeset 617:efc99e397413
test for inf()
author | kono |
---|---|
date | Wed, 06 Sep 2006 20:58:12 +0900 |
parents | 2ba903c8e749 |
children | a7f5796e540a |
files | test/float_gcc.c |
diffstat | 1 files changed, 58 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/float_gcc.c Wed Sep 06 20:58:12 2006 +0900 @@ -0,0 +1,58 @@ +#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)); +}