fixed and cleaned up fp support, optimisation yet to come
[fw/sdcc] / device / lib / _fs2ulong.c
index 01f55a49cb259ad3075fcf940acc66d9e0f277a7..0b7461435b163c45e7afaba146c0d8f0ee4cd2bc 100644 (file)
 ** uunet!motown!pipeline!phw
 */
 
-/* (c)2000: hacked a little by johan.knol@iduna.nl for sdcc */
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
 
-#include <limits.h>
-
-/* the following deal with IEEE single-precision numbers */
-#define EXCESS         126
-#define SIGNBIT                ((unsigned long)0x80000000)
-#define HIDDEN         (unsigned long)(1 << 23)
-#define SIGN(fp)       ((fp >> (8*sizeof(fp)-1)) & 1)
-#define EXP(fp)                (((fp) >> 23) & (unsigned int) 0x00FF)
-#define MANT(fp)       (((fp) & (unsigned long) 0x007FFFFF) | HIDDEN)
-#define PACK(s,e,m)    ((s) | ((e) << 23) | (m))
+#include <float.h>
 
 union float_long
 {
@@ -46,9 +37,6 @@ __fs2ulong (float a1)
   if (!fl1.l || SIGN(fl1.l))
     return (0);
 
-  if (a1>=ULONG_MAX)
-    return ULONG_MAX;
-
   exp = EXP (fl1.l) - EXCESS - 24;
   l = MANT (fl1.l);