Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 646 → Rev 647

/uspace/trunk/softfloat/include/arithmetic.h
0,0 → 1,36
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __ARITHMETIC_H__
#define __ARITHMETIC_H__
 
float32 addFloat32(float32 a, float32 b);
float32 subFloat32(float32 a, float32 b);
 
#endif
 
/uspace/trunk/softfloat/include/comparison.h
0,0 → 1,36
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __COMPARISON_H__
#define __COMPARISON_H__
 
inline int isFloat32NaN(float32 f);
inline int isFloat32SigNaN(float32 f);
 
#endif
 
/uspace/trunk/softfloat/include/sftypes.h
0,0 → 1,78
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __SFTYPES_H__
#define __SFTYPES_H__
 
 
typedef union {
float f;
struct {
#ifdef __BIG_ENDIAN__
__u32 sign:1;
__u32 exp:8;
__u32 mantisa:23;
#elif defined __LITTLE_ENDIAN__
__u32 mantisa:23;
__u32 exp:8;
__u32 sign:1;
#else
#error "Unknown endians."
#endif
} parts __attribute__ ((packed));
} float32;
typedef union {
double d;
struct {
#ifdef __BIG_ENDIAN__
__u64 sign:1;
__u64 exp:11;
__u64 mantisa:52;
#elif defined __LITTLE_ENDIAN__
__u64 mantisa:52;
__u64 exp:11;
__u64 sign:1;
#else
#error "Unknown endians."
#endif
} parts __attribute__ ((packed));
} float64;
 
#define FLOAT32_MAX 0x7f800000
#define FLOAT32_MIN 0xff800000
#define FLOAT64_MAX
#define FLOAT64_MIN
 
#define FLOAT32_BIAS 0xF7
#define FLOAT64_BIAS 0x3FF
#define FLOAT80_BIAS 0x3FFF
 
 
#endif
 
/uspace/trunk/softfloat/include/softfloat.h
29,52 → 29,6
#ifndef __SOFTFLOAT_H__
#define __SOFTFLOAT_H__
 
 
typedef union {
float f;
struct {
#ifdef __BIG_ENDIAN__
__u32 sign:1;
__u32 exp:8;
__u32 mantisa:23;
#elif defined __LITTLE_ENDIAN__
__u32 mantisa:23;
__u32 exp:8;
__u32 sign:1;
#else
#error "Unknown endians."
#endif
} parts __attribute__ ((packed));
} float32;
typedef union {
double d;
struct {
#ifdef __BIG_ENDIAN__
__u64 sign:1;
__u64 exp:11;
__u64 mantisa:52;
#elif defined __LITTLE_ENDIAN__
__u64 mantisa:52;
__u64 exp:11;
__u64 sign:1;
#else
#error "Unknown endians."
#endif
} parts __attribute__ ((packed));
} float64;
 
#define FLOAT32_MAX 0x7f800000
#define FLOAT32_MIN 0xff800000
#define FLOAT64_MAX
#define FLOAT64_MIN
 
#define FLOAT32_BIAS 0xF7
#define FLOAT64_BIAS 0x3FF
#define FLOAT80_BIAS 0x3FFF
 
 
 
float __addsf3(float a, float b);
double __adddf3(double a, double b);
long double __addtf3(long double a, long double b);
/uspace/trunk/softfloat/include/other.h
0,0 → 1,33
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __OTHER_H__
#define __OTHER_H__
 
#endif
 
/uspace/trunk/softfloat/include/conversion.h
0,0 → 1,33
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __CONVERSION_H__
#define __CONVERSION_H__
 
#endif
 
/uspace/trunk/softfloat/generic/softfloat.c
1,4 → 1,3
 
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
28,11 → 27,13
*/
 
#include<softfloat.h>
#include<sftypes.h>
#include<arithmetic.h>
#include<conversion.h>
#include<comparison.h>
#include<other.h>
 
float32 addFloat32(float32 a, float32 b);
float32 subFloat32(float32 a, float32 b);
inline int isFloat32NaN(float32 f);
inline int isFloat32SigNaN(float32 f);
/* Arithmetic functions */
 
float __addsf3(float a, float b)
{
39,7 → 40,14
float32 fa, fb;
fa.f=a;
fb.f=b;
if (fa.parts.sign!=fb.parts.sign) return subFloat32(fa,fb).f;
if (fa.parts.sign!=fb.parts.sign) {
if (fa.parts.sign) {
fa.parts.sign=0;
return subFloat32(fb,fa).f;
};
fb.parts.sign=0;
return subFloat32(fa,fb).f;
}
return addFloat32(fa,fb).f;
};
 
48,7 → 56,10
float32 fa, fb;
fa.f=a;
fb.f=b;
if (fa.parts.sign!=fb.parts.sign) return addFloat32(fa,fb).f;
if (fa.parts.sign!=fb.parts.sign) {
fb.parts.sign!=fb.parts.sign;
return addFloat32(fa,fb).f;
}
return subFloat32(fa,fb).f;
};
 
68,107 → 79,9
return fa.d;
};
 
/** Add two Float32 numbers with same signs
*/
float32 addFloat32(float32 a, float32 b)
{
int expdiff;
__u32 exp1,exp2,mant1,mant2;
expdiff=a.parts.exp - b.parts.exp;
if (expdiff<0) {
if (isFloat32NaN(b)) {
//TODO: fix SigNaN
if (isFloat32SigNaN(b)) {
};
return b;
};
if (b.parts.exp==0xFF) {
return b;
}
mant1=b.parts.mantisa;
exp1=b.parts.exp;
mant2=a.parts.mantisa;
exp2=a.parts.exp;
expdiff*=-1;
} else {
if (isFloat32NaN(a)) {
//TODO: fix SigNaN
if ((isFloat32SigNaN(a))||(isFloat32SigNaN(b))) {
};
return a;
};
if (a.parts.exp==0xFF) {
return a;
}
mant1=a.parts.mantisa;
exp1=a.parts.exp;
mant2=b.parts.mantisa;
exp2=b.parts.exp;
};
if (exp1==0) {
//both are denormalized
mant1+=mant2;
if (mant1&0xF00000) {
a.parts.exp=1;
};
a.parts.mantisa=mant1;
return a;
};
// create some space for rounding
mant1<<=6;
mant2<<=6;
mant1|=0x20000000; //add hidden bit
if (exp2==0) {
--expdiff;
} else {
mant2|=0x20000000; //hidden bit
};
if (expdiff>24) {
goto done;
};
mant2>>=expdiff;
mant1+=mant2;
done:
if (mant1&0x40000000) {
++exp1;
mant1>>=1;
};
//rounding - if first bit after mantisa is set then round up
mant1+=0x20;
a.parts.exp=exp1;
a.parts.mantisa=mant1>>6;
return a;
};
/* Conversion functions */
 
/** Substract two float32 numbers with same signs
*/
float32 subFloat32(float32 a, float32 b)
{
};
/* Comparison functions */
 
inline int isFloat32NaN(float32 f)
{ /* NaN : exp = 0xff and nonzero mantisa */
return ((f.parts.exp==0xFF)&&(f.parts.mantisa));
};
/* Other functions */
 
inline int isFloat32SigNaN(float32 f)
{ /* SigNaN : exp = 0xff mantisa = 1xxxxx..x (binary), where at least one x is nonzero */
return ((f.parts.exp==0xFF)&&(f.parts.mantisa>0x400000));
};
 
/uspace/trunk/softfloat/generic/other.c
0,0 → 1,29
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
 
/uspace/trunk/softfloat/generic/conversion.c
0,0 → 1,28
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/uspace/trunk/softfloat/generic/arithmetic.c
0,0 → 1,125
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include<sftypes.h>
#include<arithmetic.h>
 
/** Add two Float32 numbers with same signs
*/
float32 addFloat32(float32 a, float32 b)
{
int expdiff;
__u32 exp1,exp2,mant1,mant2;
expdiff=a.parts.exp - b.parts.exp;
if (expdiff<0) {
if (isFloat32NaN(b)) {
//TODO: fix SigNaN
if (isFloat32SigNaN(b)) {
};
return b;
};
if (b.parts.exp==0xFF) {
return b;
}
mant1=b.parts.mantisa;
exp1=b.parts.exp;
mant2=a.parts.mantisa;
exp2=a.parts.exp;
expdiff*=-1;
} else {
if (isFloat32NaN(a)) {
//TODO: fix SigNaN
if ((isFloat32SigNaN(a))||(isFloat32SigNaN(b))) {
};
return a;
};
if (a.parts.exp==0xFF) {
return a;
}
mant1=a.parts.mantisa;
exp1=a.parts.exp;
mant2=b.parts.mantisa;
exp2=b.parts.exp;
};
if (exp1==0) {
//both are denormalized
mant1+=mant2;
if (mant1&0xF00000) {
a.parts.exp=1;
};
a.parts.mantisa=mant1;
return a;
};
// create some space for rounding
mant1<<=6;
mant2<<=6;
mant1|=0x20000000; //add hidden bit
if (exp2==0) {
--expdiff;
} else {
mant2|=0x20000000; //hidden bit
};
if (expdiff>24) {
goto done;
};
mant2>>=expdiff;
mant1+=mant2;
done:
if (mant1&0x40000000) {
++exp1;
mant1>>=1;
};
//rounding - if first bit after mantisa is set then round up
mant1+=0x20;
a.parts.exp=exp1;
a.parts.mantisa=mant1>>6;
return a;
};
 
/** Substract two float32 numbers with same signs
*/
float32 subFloat32(float32 a, float32 b)
{
};
 
/uspace/trunk/softfloat/generic/comparison.c
0,0 → 1,41
/*
* Copyright (C) 2005 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include<sftypes.h>
#include<comparison.h>
 
inline int isFloat32NaN(float32 f)
{ /* NaN : exp = 0xff and nonzero mantisa */
return ((f.parts.exp==0xFF)&&(f.parts.mantisa));
};
 
inline int isFloat32SigNaN(float32 f)
{ /* SigNaN : exp = 0xff mantisa = 1xxxxx..x (binary), where at least one x is nonzero */
return ((f.parts.exp==0xFF)&&(f.parts.mantisa>0x400000));
};