Revision 75d62a58 fpu/softfloat-native.c
b/fpu/softfloat-native.c | ||
---|---|---|
59 | 59 |
return (float32)v; |
60 | 60 |
} |
61 | 61 |
|
62 |
float32 uint32_to_float32(unsigned int v STATUS_PARAM) |
|
63 |
{ |
|
64 |
return (float32)v; |
|
65 |
} |
|
66 |
|
|
62 | 67 |
float64 int32_to_float64(int v STATUS_PARAM) |
63 | 68 |
{ |
64 | 69 |
return (float64)v; |
65 | 70 |
} |
66 | 71 |
|
72 |
float64 uint32_to_float64(unsigned int v STATUS_PARAM) |
|
73 |
{ |
|
74 |
return (float64)v; |
|
75 |
} |
|
76 |
|
|
67 | 77 |
#ifdef FLOATX80 |
68 | 78 |
floatx80 int32_to_floatx80(int v STATUS_PARAM) |
69 | 79 |
{ |
... | ... | |
74 | 84 |
{ |
75 | 85 |
return (float32)v; |
76 | 86 |
} |
87 |
float32 uint64_to_float32( uint64_t v STATUS_PARAM) |
|
88 |
{ |
|
89 |
return (float32)v; |
|
90 |
} |
|
77 | 91 |
float64 int64_to_float64( int64_t v STATUS_PARAM) |
78 | 92 |
{ |
79 | 93 |
return (float64)v; |
80 | 94 |
} |
95 |
float64 uint64_to_float64( uint64_t v STATUS_PARAM) |
|
96 |
{ |
|
97 |
return (float64)v; |
|
98 |
} |
|
81 | 99 |
#ifdef FLOATX80 |
82 | 100 |
floatx80 int64_to_floatx80( int64_t v STATUS_PARAM) |
83 | 101 |
{ |
... | ... | |
132 | 150 |
} |
133 | 151 |
#endif |
134 | 152 |
|
153 |
unsigned int float32_to_uint32( float32 a STATUS_PARAM) |
|
154 |
{ |
|
155 |
int64_t v; |
|
156 |
unsigned int res; |
|
157 |
|
|
158 |
v = llrintf(a); |
|
159 |
if (v < 0) { |
|
160 |
res = 0; |
|
161 |
} else if (v > 0xffffffff) { |
|
162 |
res = 0xffffffff; |
|
163 |
} else { |
|
164 |
res = v; |
|
165 |
} |
|
166 |
return res; |
|
167 |
} |
|
168 |
unsigned int float32_to_uint32_round_to_zero( float32 a STATUS_PARAM) |
|
169 |
{ |
|
170 |
int64_t v; |
|
171 |
unsigned int res; |
|
172 |
|
|
173 |
v = (int64_t)a; |
|
174 |
if (v < 0) { |
|
175 |
res = 0; |
|
176 |
} else if (v > 0xffffffff) { |
|
177 |
res = 0xffffffff; |
|
178 |
} else { |
|
179 |
res = v; |
|
180 |
} |
|
181 |
return res; |
|
182 |
} |
|
183 |
|
|
135 | 184 |
/*---------------------------------------------------------------------------- |
136 | 185 |
| Software IEC/IEEE single-precision operations. |
137 | 186 |
*----------------------------------------------------------------------------*/ |
... | ... | |
218 | 267 |
} |
219 | 268 |
#endif |
220 | 269 |
|
270 |
unsigned int float64_to_uint32( float64 a STATUS_PARAM) |
|
271 |
{ |
|
272 |
int64_t v; |
|
273 |
unsigned int res; |
|
274 |
|
|
275 |
v = llrint(a); |
|
276 |
if (v < 0) { |
|
277 |
res = 0; |
|
278 |
} else if (v > 0xffffffff) { |
|
279 |
res = 0xffffffff; |
|
280 |
} else { |
|
281 |
res = v; |
|
282 |
} |
|
283 |
return res; |
|
284 |
} |
|
285 |
unsigned int float64_to_uint32_round_to_zero( float64 a STATUS_PARAM) |
|
286 |
{ |
|
287 |
int64_t v; |
|
288 |
unsigned int res; |
|
289 |
|
|
290 |
v = (int64_t)a; |
|
291 |
if (v < 0) { |
|
292 |
res = 0; |
|
293 |
} else if (v > 0xffffffff) { |
|
294 |
res = 0xffffffff; |
|
295 |
} else { |
|
296 |
res = v; |
|
297 |
} |
|
298 |
return res; |
|
299 |
} |
|
300 |
uint64_t float64_to_uint64 (float64 a STATUS_PARAM) |
|
301 |
{ |
|
302 |
int64_t v; |
|
303 |
|
|
304 |
v = llrint(a + (float64)INT64_MIN); |
|
305 |
|
|
306 |
return v - INT64_MIN; |
|
307 |
} |
|
308 |
uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM) |
|
309 |
{ |
|
310 |
int64_t v; |
|
311 |
|
|
312 |
v = (int64_t)(a + (float64)INT64_MIN); |
|
313 |
|
|
314 |
return v - INT64_MIN; |
|
315 |
} |
|
316 |
|
|
221 | 317 |
/*---------------------------------------------------------------------------- |
222 | 318 |
| Software IEC/IEEE double-precision operations. |
223 | 319 |
*----------------------------------------------------------------------------*/ |
Also available in: Unified diff