00001 #ifndef __SOFTFLOAT_H__
00002 #define __SOFTFLOAT_H__
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
00029
00030
00031
00032
00033
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define FLOATX80
00046 #define FLOAT128
00047
00048
00049
00050
00051 typedef unsigned int float32;
00052 typedef unsigned long long float64;
00053 #ifdef FLOATX80
00054 typedef struct {
00055 unsigned short high;
00056 unsigned long long low;
00057 } floatx80;
00058 #endif
00059 #ifdef FLOAT128
00060 typedef struct {
00061 unsigned long long high, low;
00062 } float128;
00063 #endif
00064
00065
00066
00067
00068 extern int float_detect_tininess;
00069 enum {
00070 float_tininess_after_rounding = 0,
00071 float_tininess_before_rounding = 1
00072 };
00073
00074
00075
00076
00077 extern int8 float_rounding_mode;
00078 enum {
00079 float_round_nearest_even = 0,
00080 float_round_to_zero = 1,
00081 float_round_up = 2,
00082 float_round_down = 3
00083 };
00084
00085
00086
00087
00088 extern int float_exception_flags;
00089 enum {
00090 float_flag_inexact = 1,
00091 float_flag_divbyzero = 2,
00092 float_flag_underflow = 4,
00093 float_flag_overflow = 8,
00094 float_flag_invalid = 16
00095 };
00096
00097
00098
00099
00100 extern int float_rounding_flags;
00101 enum {
00102 float_rounding_no = 0,
00103 float_rounding_yes = 1
00104 };
00105
00106
00107
00108
00109
00110 void float_raise( int );
00111
00112
00113
00114
00115 float32 int32_to_float32( int );
00116 float64 int32_to_float64( int );
00117 #ifdef FLOATX80
00118 floatx80 int32_to_floatx80( int );
00119 #endif
00120 #ifdef FLOAT128
00121 float128 int32_to_float128( int );
00122 #endif
00123 float32 int64_to_float32( long long );
00124 float64 int64_to_float64( long long );
00125 #ifdef FLOATX80
00126 floatx80 int64_to_floatx80( long long );
00127 #endif
00128 #ifdef FLOAT128
00129 float128 int64_to_float128( long long );
00130 #endif
00131
00132
00133
00134
00135 int float32_to_int32( float32 );
00136 int float32_to_int32_round_to_zero( float32 );
00137 long long float32_to_int64( float32 );
00138 long long float32_to_int64_round_to_zero( float32 );
00139 float64 float32_to_float64( float32 );
00140 #ifdef FLOATX80
00141 floatx80 float32_to_floatx80( float32 );
00142 #endif
00143 #ifdef FLOAT128
00144 float128 float32_to_float128( float32 );
00145 #endif
00146
00147
00148
00149
00150 float32 float32_round_to_int( float32 );
00151 float32 float32_add( float32, float32 );
00152 float32 float32_sub( float32, float32 );
00153 float32 float32_mul( float32, float32 );
00154 float32 float32_div( float32, float32 );
00155 float32 float32_rem( float32, float32 );
00156 float32 float32_sqrt( float32 );
00157 int float32_eq( float32, float32 );
00158 int float32_le( float32, float32 );
00159 int float32_lt( float32, float32 );
00160 int float32_eq_signaling( float32, float32 );
00161 int float32_le_quiet( float32, float32 );
00162 int float32_lt_quiet( float32, float32 );
00163 int float32_is_signaling_nan( float32 );
00164
00165
00166
00167
00168 int float64_to_int32( float64 );
00169 int float64_to_int32_round_to_zero( float64 );
00170 long long float64_to_int64( float64 );
00171 long long float64_to_int64_round_to_zero( float64 );
00172 float32 float64_to_float32( float64 );
00173 #ifdef FLOATX80
00174 floatx80 float64_to_floatx80( float64 );
00175 #endif
00176 #ifdef FLOAT128
00177 float128 float64_to_float128( float64 );
00178 #endif
00179
00180
00181
00182
00183 float64 float64_round_to_int( float64 );
00184 float64 float64_add( float64, float64 );
00185 float64 float64_sub( float64, float64 );
00186 float64 float64_mul( float64, float64 );
00187 float64 float64_div( float64, float64 );
00188 float64 float64_rem( float64, float64 );
00189 float64 float64_sqrt( float64 );
00190 int float64_eq( float64, float64 );
00191 int float64_le( float64, float64 );
00192 int float64_lt( float64, float64 );
00193 int float64_eq_signaling( float64, float64 );
00194 int float64_le_quiet( float64, float64 );
00195 int float64_lt_quiet( float64, float64 );
00196 int float64_is_signaling_nan( float64 );
00197
00198 #ifdef FLOATX80
00199
00200
00201
00202
00203 int floatx80_to_int32( floatx80 );
00204 int floatx80_to_int32_round_to_zero( floatx80 );
00205 long long floatx80_to_int64( floatx80 );
00206 long long floatx80_to_int64_round_to_zero( floatx80 );
00207 float32 floatx80_to_float32( floatx80 );
00208 float64 floatx80_to_float64( floatx80 );
00209 #ifdef FLOAT128
00210 float128 floatx80_to_float128( floatx80 );
00211 #endif
00212
00213
00214
00215
00216
00217 extern int floatx80_rounding_precision;
00218
00219
00220
00221
00222 floatx80 floatx80_round_to_int( floatx80 );
00223 floatx80 floatx80_add( floatx80, floatx80 );
00224 floatx80 floatx80_sub( floatx80, floatx80 );
00225 floatx80 floatx80_mul( floatx80, floatx80 );
00226 floatx80 floatx80_div( floatx80, floatx80 );
00227 floatx80 floatx80_rem( floatx80, floatx80 );
00228 floatx80 floatx80_sqrt( floatx80 );
00229 int floatx80_eq( floatx80, floatx80 );
00230 int floatx80_le( floatx80, floatx80 );
00231 int floatx80_lt( floatx80, floatx80 );
00232 int floatx80_eq_signaling( floatx80, floatx80 );
00233 int floatx80_le_quiet( floatx80, floatx80 );
00234 int floatx80_lt_quiet( floatx80, floatx80 );
00235 int floatx80_is_signaling_nan( floatx80 );
00236
00237 #endif
00238
00239 #ifdef FLOAT128
00240
00241
00242
00243
00244 int float128_to_int32( float128 );
00245 int float128_to_int32_round_to_zero( float128 );
00246 long long float128_to_int64( float128 );
00247 long long float128_to_int64_round_to_zero( float128 );
00248 float32 float128_to_float32( float128 );
00249 float64 float128_to_float64( float128 );
00250 #ifdef FLOATX80
00251 floatx80 float128_to_floatx80( float128 );
00252 #endif
00253
00254
00255
00256
00257 float128 float128_round_to_int( float128 );
00258 float128 float128_add( float128, float128 );
00259 float128 float128_sub( float128, float128 );
00260 float128 float128_mul( float128, float128 );
00261 float128 float128_div( float128, float128 );
00262 float128 float128_rem( float128, float128 );
00263 float128 float128_sqrt( float128 );
00264 int float128_eq( float128, float128 );
00265 int float128_le( float128, float128 );
00266 int float128_lt( float128, float128 );
00267 int float128_eq_signaling( float128, float128 );
00268 int float128_le_quiet( float128, float128 );
00269 int float128_lt_quiet( float128, float128 );
00270 int float128_is_signaling_nan( float128 );
00271
00272 #endif
00273
00274 #ifdef __cplusplus
00275 };
00276 #endif
00277
00278
00279 #endif