Revision 75d62a58 fpu/softfloat.c
b/fpu/softfloat.c | ||
---|---|---|
1164 | 1164 |
|
1165 | 1165 |
} |
1166 | 1166 |
|
1167 |
float64 uint64_to_float32( uint64 a STATUS_PARAM ) |
|
1168 |
{ |
|
1169 |
int8 shiftCount; |
|
1170 |
|
|
1171 |
if ( a == 0 ) return 0; |
|
1172 |
shiftCount = countLeadingZeros64( a ) - 40; |
|
1173 |
if ( 0 <= shiftCount ) { |
|
1174 |
return packFloat32( 1 > 0, 0x95 - shiftCount, a<<shiftCount ); |
|
1175 |
} |
|
1176 |
else { |
|
1177 |
shiftCount += 7; |
|
1178 |
if ( shiftCount < 0 ) { |
|
1179 |
shift64RightJamming( a, - shiftCount, &a ); |
|
1180 |
} |
|
1181 |
else { |
|
1182 |
a <<= shiftCount; |
|
1183 |
} |
|
1184 |
return roundAndPackFloat32( 1 > 0, 0x9C - shiftCount, a STATUS_VAR ); |
|
1185 |
} |
|
1186 |
} |
|
1187 |
|
|
1167 | 1188 |
/*---------------------------------------------------------------------------- |
1168 | 1189 |
| Returns the result of converting the 64-bit two's complement integer `a' |
1169 | 1190 |
| to the double-precision floating-point format. The conversion is performed |
... | ... | |
1183 | 1204 |
|
1184 | 1205 |
} |
1185 | 1206 |
|
1207 |
float64 uint64_to_float64( uint64 a STATUS_PARAM ) |
|
1208 |
{ |
|
1209 |
if ( a == 0 ) return 0; |
|
1210 |
return normalizeRoundAndPackFloat64( 0, 0x43C, a STATUS_VAR ); |
|
1211 |
|
|
1212 |
} |
|
1213 |
|
|
1186 | 1214 |
#ifdef FLOATX80 |
1187 | 1215 |
|
1188 | 1216 |
/*---------------------------------------------------------------------------- |
... | ... | |
5282 | 5310 |
return res; |
5283 | 5311 |
} |
5284 | 5312 |
|
5313 |
uint64_t float64_to_uint64 (float64 a STATUS_PARAM) |
|
5314 |
{ |
|
5315 |
int64_t v; |
|
5316 |
|
|
5317 |
v = int64_to_float64(INT64_MIN STATUS_VAR); |
|
5318 |
v = float64_to_int64((a + v) STATUS_VAR); |
|
5319 |
|
|
5320 |
return v - INT64_MIN; |
|
5321 |
} |
|
5322 |
|
|
5323 |
uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM) |
|
5324 |
{ |
|
5325 |
int64_t v; |
|
5326 |
|
|
5327 |
v = int64_to_float64(INT64_MIN STATUS_VAR); |
|
5328 |
v = float64_to_int64_round_to_zero((a + v) STATUS_VAR); |
|
5329 |
|
|
5330 |
return v - INT64_MIN; |
|
5331 |
} |
|
5332 |
|
|
5285 | 5333 |
#define COMPARE(s, nan_exp) \ |
5286 | 5334 |
INLINE int float ## s ## _compare_internal( float ## s a, float ## s b, \ |
5287 | 5335 |
int is_quiet STATUS_PARAM ) \ |
Also available in: Unified diff