Changeset afffa1e in mainline
- Timestamp:
- 2006-02-20T23:12:05Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2cb202e
- Parents:
- d9f51ccc
- Location:
- softfloat
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
softfloat/generic/conversion.c
rd9f51ccc rafffa1e 29 29 #include "sftypes.h" 30 30 #include "conversion.h" 31 #include "comparison.h" 31 32 32 33 float64 convertFloat32ToFloat64(float32 a) … … 67 68 return result; 68 69 69 } ;70 } 70 71 71 72 float32 convertFloat64ToFloat32(float64 a) … … 136 137 result.parts.fraction = a.parts.fraction >> (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE); 137 138 return result; 138 }; 139 139 } 140 141 142 /** Helping procedure for converting float32 to uint32 143 * @param a floating point number in normalized form (no NaNs or Inf are checked ) 144 * @return unsigned integer 145 */ 146 static __u32 _float32_to_uint32_helper(float32 a) 147 { 148 __u32 frac; 149 150 if (a.parts.exp < FLOAT32_BIAS) { 151 /*TODO: rounding*/ 152 return 0; 153 } 154 155 frac = a.parts.fraction; 156 157 frac |= FLOAT32_HIDDEN_BIT_MASK; 158 /* shift fraction to left so hidden bit will be the most significant bit */ 159 frac <<= 32 - FLOAT32_FRACTION_SIZE - 1; 160 161 frac >>= 32 - (a.parts.exp - FLOAT32_BIAS) - 1; 162 if ((a.parts.sign == 1) && (frac != 0)) { 163 frac = ~frac; 164 ++frac; 165 } 166 167 return frac; 168 } 169 170 /* Convert float to unsigned int32 171 * FIXME: Im not sure what to return if overflow/underflow happens 172 * - now its the biggest or the smallest int 173 */ 174 __u32 float32_to_uint32(float32 a) 175 { 176 if (isFloat32NaN(a)) { 177 return MAX_UINT32; 178 } 179 180 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) { 181 if (a.parts.sign) { 182 return MIN_UINT32; 183 } 184 return MAX_UINT32; 185 } 186 187 return _float32_to_uint32_helper(a); 188 } 189 190 /* Convert float to signed int32 191 * FIXME: Im not sure what to return if overflow/underflow happens 192 * - now its the biggest or the smallest int 193 */ 194 __s32 float32_to_int32(float32 a) 195 { 196 if (isFloat32NaN(a)) { 197 return MAX_INT32; 198 } 199 200 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) { 201 if (a.parts.sign) { 202 return MIN_INT32; 203 } 204 return MAX_INT32; 205 } 206 return _float32_to_uint32_helper(a); 207 } 208 209 210 -
softfloat/generic/softfloat.c
rd9f51ccc rafffa1e 39 39 #include<other.h> 40 40 41 #include<arch.h> 42 #include<types.h> 43 #include<functions.h> 44 41 45 /* Arithmetic functions */ 42 46 … … 161 165 } 162 166 167 int __fixsfsi(float a) 168 { 169 float32 fa; 170 fa.f = a; 171 172 return float32_to_int(fa); 173 } 174 int __fixdfsi(double a) 175 { 176 } 177 178 long __fixsfdi(float a) 179 { 180 float32 fa; 181 fa.f = a; 182 183 return float32_to_long(fa); 184 } 185 long __fixdfdi(double a) 186 { 187 } 188 189 long long __fixsfti(float a) 190 { 191 } 192 long long __fixdfti(double a) 193 { 194 } 195 196 unsigned int __fixunssfsi(float a) 197 { 198 float32 fa; 199 fa.f = a; 200 201 return float32_to_uint(fa); 202 } 203 unsigned int __fixunsdfsi(double a) 204 { 205 } 206 207 unsigned long __fixunssfdi(float a) 208 { 209 float32 fa; 210 fa.f = a; 211 212 return float32_to_long(fa); 213 } 214 unsigned long __fixunsdfdi(double a) 215 { 216 } 217 218 unsigned long long __fixunssfti(float a) 219 { 220 } 221 unsigned long long __fixunsdfti(double a) 222 { 223 } 224 225 float __floatsisf(int i) 226 { 227 } 228 double __floatsidf(int i) 229 { 230 } 231 232 float __floatdisf(long i) 233 { 234 } 235 double __floatdidf(long i) 236 { 237 } 238 239 float __floattisf(long long i) 240 { 241 } 242 double __floattidf(long long i) 243 { 244 } 245 246 float __floatunsisf(unsigned int i) 247 { 248 } 249 double __floatunsidf(unsigned int i) 250 { 251 } 252 253 float __floatundisf(unsigned long i) 254 { 255 } 256 double __floatundidf(unsigned long i) 257 { 258 } 259 260 float __floatuntisf(unsigned long long i) 261 { 262 } 263 double __floatuntidf(unsigned long long i) 264 { 265 } 266 267 /* Comparison functions */ 163 268 /* Comparison functions */ 164 269 -
softfloat/include/sftypes.h
rd9f51ccc rafffa1e 29 29 #ifndef __SFTYPES_H__ 30 30 #define __SFTYPES_H__ 31 32 #include <types.h> 33 #include <arch.h> 31 34 32 35 typedef union { -
softfloat/include/softfloat.h
rd9f51ccc rafffa1e 112 112 long double __floattixf(long long i); 113 113 114 float __floatunsisf(unsigned int i); 115 double __floatunsidf(unsigned int i); 116 long double __floatunsitf(unsigned int i); 117 long double __floatunsixf(unsigned int i); 118 119 float __floatundisf(unsigned long i); 120 double __floatundidf(unsigned long i); 121 long double __floatunditf(unsigned long i); 122 long double __floatundixf(unsigned long i); 123 124 float __floatuntisf(unsigned long long i); 125 double __floatuntidf(unsigned long long i); 126 long double __floatuntitf(unsigned long long i); 127 long double __floatuntixf(unsigned long long i); 128 114 129 int __cmpsf2(float a, float b); 115 130 int __cmpdf2(double a, double b);
Note:
See TracChangeset
for help on using the changeset viewer.