This commit is contained in:
igor-m
2014-04-11 22:55:29 +02:00
parent bcff791a3c
commit 5b1496e5c3

View File

@@ -11,15 +11,31 @@
* isnan(x) returns 1 is x is nan, else 0; * isnan(x) returns 1 is x is nan, else 0;
* no branching! * no branching!
*/ */
int isnanf (float x)
{
long lx = *(long*) &x;
typedef union {
float x;
struct {
long lxx;
};
} ival;
//int isnanf (float x)
//{
// long lx = *(long*) &x;
// lx = 0x7f800000 - (lx & 0x7fffffff);
// return (int) (((unsigned long) lx) >> 31);
//}
int isnanf (float xx) {
ival temp;
temp.x = xx;
long lx = temp.lxx;
lx = 0x7f800000 - (lx & 0x7fffffff); lx = 0x7f800000 - (lx & 0x7fffffff);
return (int) (((unsigned long) lx) >> 31); return (int) (((unsigned long) lx) >> 31);
} }
/* /*
* For PIC32, double is the same as float. * For PIC32, double is the same as float.
*/ */
int isnan (double x) __attribute__((alias ("isnanf"))); //int isnan (double x) __attribute__((alias ("isnanf")));