00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00035 #ifndef __SFTYPES_H__
00036 #define __SFTYPES_H__
00037 
00038 #include <byteorder.h>
00039 #include <stdint.h>
00040 
00041 typedef union {
00042         float f;
00043         uint32_t binary;
00044         
00045         struct {
00046 #if defined(__BE__)
00047                 uint32_t sign : 1;
00048                 uint32_t exp : 8;
00049                 uint32_t fraction : 23;
00050 #elif defined(__LE__)
00051                 uint32_t fraction : 23;
00052                 uint32_t exp : 8;
00053                 uint32_t sign : 1;
00054 #else
00055         #error Unknown endianess
00056 #endif
00057         } parts __attribute__ ((packed));
00058 } float32;
00059 
00060 typedef union {
00061         double d;
00062         uint64_t binary;
00063         
00064         struct {
00065 #if defined(__BE__)
00066                 uint64_t sign : 1;
00067                 uint64_t exp : 11;
00068                 uint64_t fraction : 52;
00069 #elif defined(__LE__)
00070                 uint64_t fraction : 52;
00071                 uint64_t exp : 11;
00072                 uint64_t sign : 1;
00073 #else
00074         #error Unknown endianess
00075 #endif
00076         } parts __attribute__ ((packed));
00077 } float64;
00078 
00079 #define FLOAT32_MAX  0x7f800000
00080 #define FLOAT32_MIN  0xff800000
00081 #define FLOAT64_MAX
00082 #define FLOAT64_MIN
00083 
00084 
00085 
00086 
00087 
00088 
00089 #define FLOAT32_NAN     0x7FC00001
00090 #define FLOAT32_SIGNAN  0x7F800001
00091 #define FLOAT32_INF     0x7F800000
00092 
00093 #define FLOAT64_NAN     0x7FF8000000000001ll
00094 #define FLOAT64_SIGNAN  0x7FF0000000000001ll
00095 #define FLOAT64_INF     0x7FF0000000000000ll
00096 
00097 #define FLOAT32_FRACTION_SIZE  23
00098 #define FLOAT64_FRACTION_SIZE  52
00099 
00100 #define FLOAT32_HIDDEN_BIT_MASK  0x800000
00101 #define FLOAT64_HIDDEN_BIT_MASK  0x10000000000000ll
00102 
00103 #define FLOAT32_MAX_EXPONENT  0xFF
00104 #define FLOAT64_MAX_EXPONENT  0x7FF
00105 
00106 #define FLOAT32_BIAS  0x7F
00107 #define FLOAT64_BIAS  0x3FF
00108 #define FLOAT80_BIAS  0x3FFF
00109 
00110 #endif
00111