mirror of
https://git.planet-casio.com/Lephenixnoir/OpenLibm.git
synced 2025-07-04 11:36:53 +02:00
fpclassify definition
This commit is contained in:
parent
a9d723a19e
commit
ac201ff1ac
2 changed files with 78 additions and 5 deletions
2
Make.inc
2
Make.inc
|
@ -1,5 +1,5 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-O2 -I. -I../include -I../ld128 -I../src -D__BSD_VISIBLE -Wno-implicit-function-declaration
|
CFLAGS=-Wall -O2 -I. -I../include -I../ld128 -I../src -D__BSD_VISIBLE -Wno-implicit-function-declaration
|
||||||
|
|
||||||
default: all
|
default: all
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,80 @@
|
||||||
|
|
||||||
#include "fpmath.h"
|
#include "fpmath.h"
|
||||||
|
|
||||||
#warning "todo: fpclassify needs to be defined"
|
//#define FP_INFINITE 0x01
|
||||||
int __fpclassifyd(double);
|
//#define FP_NAN 0x02
|
||||||
int __fpclassifyf(float);
|
//#define FP_NORMAL 0x04
|
||||||
int __fpclassifyl(long double);
|
//#define FP_SUBNORMAL 0x08
|
||||||
|
//#define FP_ZERO 0x10
|
||||||
|
//#define fpclassify(x) \
|
||||||
|
// ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
|
||||||
|
// : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
|
||||||
|
// : __fpclassifyl(x))
|
||||||
|
//
|
||||||
|
|
||||||
|
int
|
||||||
|
__fpclassifyd(double d)
|
||||||
|
{
|
||||||
|
union IEEEd2bits u;
|
||||||
|
|
||||||
|
u.d = d;
|
||||||
|
if (u.bits.exp == 2047) {
|
||||||
|
if (u.bits.manl == 0 && u.bits.manh == 0) {
|
||||||
|
return FP_INFINITE;
|
||||||
|
} else {
|
||||||
|
return FP_NAN;
|
||||||
|
}
|
||||||
|
} else if (u.bits.exp != 0) {
|
||||||
|
return FP_NORMAL;
|
||||||
|
} else if (u.bits.manl == 0 && u.bits.manh == 0) {
|
||||||
|
return FP_ZERO;
|
||||||
|
} else {
|
||||||
|
return FP_SUBNORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
__fpclassifyf(float f)
|
||||||
|
{
|
||||||
|
union IEEEf2bits u;
|
||||||
|
|
||||||
|
u.f = f;
|
||||||
|
if (u.bits.exp == 255) {
|
||||||
|
if (u.bits.man == 0) {
|
||||||
|
return FP_INFINITE;
|
||||||
|
} else {
|
||||||
|
return FP_NAN;
|
||||||
|
}
|
||||||
|
} else if (u.bits.exp != 0) {
|
||||||
|
return FP_NORMAL;
|
||||||
|
} else if (u.bits.man == 0) {
|
||||||
|
return FP_ZERO;
|
||||||
|
} else {
|
||||||
|
return FP_SUBNORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
__fpclassifyl(long double e)
|
||||||
|
{
|
||||||
|
union IEEEl2bits u;
|
||||||
|
|
||||||
|
u.e = e;
|
||||||
|
mask_nbit_l(u);
|
||||||
|
if (u.bits.exp == 32767) {
|
||||||
|
if (u.bits.manl == 0 && u.bits.manh == 0) {
|
||||||
|
return FP_INFINITE;
|
||||||
|
} else {
|
||||||
|
return FP_NAN;
|
||||||
|
}
|
||||||
|
} else if (u.bits.exp != 0) {
|
||||||
|
return FP_NORMAL;
|
||||||
|
} else if (u.bits.manl == 0 && u.bits.manh == 0) {
|
||||||
|
return FP_ZERO;
|
||||||
|
} else {
|
||||||
|
return FP_SUBNORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue