POK
|
00001 /* 00002 * POK header 00003 * 00004 * The following file is a part of the POK project. Any modification should 00005 * made according to the POK licence. You CANNOT use this file or a part of 00006 * this file is this part of a file for your own project 00007 * 00008 * For more information on the POK licence, please see our LICENCE FILE 00009 * 00010 * Please follow the coding guidelines described in doc/CODING_GUIDELINES 00011 * 00012 * Copyright (c) 2007-2009 POK team 00013 * 00014 * Created by julien on Sat Jan 31 15:49:24 2009 00015 */ 00016 00017 #ifdef POK_NEEDS_LIBMATH 00018 00019 #include <libm.h> 00020 #include <types.h> 00021 #include "math_private.h" 00022 00023 int 00024 __fpclassifyf (float x) 00025 { 00026 uint32_t w; 00027 00028 GET_FLOAT_WORD(w,x); 00029 00030 if (w == 0x00000000 || w == 0x80000000) 00031 return FP_ZERO; 00032 else if ((w >= 0x00800000 && w <= 0x7f7fffff) || 00033 (w >= 0x80800000 && w <= 0xff7fffff)) 00034 return FP_NORMAL; 00035 else if ((w >= 0x00000001 && w <= 0x007fffff) || 00036 (w >= 0x80000001 && w <= 0x807fffff)) 00037 return FP_SUBNORMAL; 00038 else if (w == 0x7f800000 || w == 0xff800000) 00039 return FP_INFINITE; 00040 else 00041 return FP_NAN; 00042 } 00043 00044 int 00045 __fpclassifyd (double x) 00046 { 00047 uint32_t msw, lsw; 00048 00049 EXTRACT_WORDS(msw,lsw,x); 00050 00051 if ((msw == 0x00000000 && lsw == 0x00000000) || 00052 (msw == 0x80000000 && lsw == 0x00000000)) 00053 return FP_ZERO; 00054 else if ((msw >= 0x00100000 && msw <= 0x7fefffff) || 00055 (msw >= 0x80100000 && msw <= 0xffefffff)) 00056 return FP_NORMAL; 00057 /* 00058 else if ((msw >= 0x00000000 && msw <= 0x000fffff) || 00059 bugfix : msw is an uint32_t (unsigned) value, always positive 00060 */ 00061 else if ((msw <= 0x000fffff) || 00062 (msw >= 0x80000000 && msw <= 0x800fffff)) 00063 /* zero is already handled above */ 00064 return FP_SUBNORMAL; 00065 else if ((msw == 0x7ff00000 && lsw == 0x00000000) || 00066 (msw == 0xfff00000 && lsw == 0x00000000)) 00067 return FP_INFINITE; 00068 else 00069 return FP_NAN; 00070 } 00071 00072 00073 #endif