Changeset f37d769 in mainline
- Timestamp:
- 2006-02-24T18:24:07Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fbd6f81
- Parents:
- ba5870d
- Location:
- softfloat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
softfloat/generic/conversion.c
rba5870d rf37d769 387 387 } 388 388 389 390 389 /** Convert unsigned integer to float32 391 390 * … … 486 485 return result; 487 486 } 487 488 /** Convert unsigned integer to float64 489 * 490 * 491 */ 492 float64 uint32_to_float64(__u32 i) 493 { 494 int counter; 495 __s32 exp; 496 float64 result; 497 __u64 frac; 498 499 result.parts.sign = 0; 500 result.parts.fraction = 0; 501 502 counter = countZeroes32(i); 503 504 exp = FLOAT64_BIAS + 32 - counter - 1; 505 506 if (counter == 32) { 507 result.binary = 0; 508 return result; 509 } 510 511 frac = i; 512 frac <<= counter + 32 - 1; 513 514 roundFloat64(&exp, &frac); 515 516 result.parts.fraction = frac >> 10; 517 result.parts.exp = exp; 518 519 return result; 520 } 521 522 float64 int32_to_float64(__s32 i) 523 { 524 float64 result; 525 526 if (i < 0) { 527 result = uint32_to_float64((__u32)(-i)); 528 } else { 529 result = uint32_to_float64((__u32)i); 530 } 531 532 result.parts.sign = i < 0; 533 534 return result; 535 } 536 537 538 float64 uint64_to_float64(__u64 i) 539 { 540 int counter; 541 __s32 exp; 542 float64 result; 543 544 result.parts.sign = 0; 545 result.parts.fraction = 0; 546 547 counter = countZeroes64(i); 548 549 exp = FLOAT64_BIAS + 64 - counter - 1; 550 551 if (counter == 64) { 552 result.binary = 0; 553 return result; 554 } 555 556 if (counter > 0) { 557 i <<= counter - 1; 558 } else { 559 i >>= 1; 560 } 561 562 roundFloat64(&exp, &i); 563 564 result.parts.fraction = i >> 10; 565 result.parts.exp = exp; 566 return result; 567 } 568 569 float64 int64_to_float64(__s64 i) 570 { 571 float64 result; 572 573 if (i < 0) { 574 result = uint64_to_float64((__u64)(-i)); 575 } else { 576 result = uint64_to_float64((__u64)i); 577 } 578 579 result.parts.sign = i < 0; 580 581 return result; 582 } 583 584 -
softfloat/generic/softfloat.c
rba5870d rf37d769 264 264 double __floatsidf(int i) 265 265 { 266 float64 da; 267 268 da = int_to_float64(i); 269 return da.d; 266 270 } 267 271 … … 275 279 double __floatdidf(long i) 276 280 { 281 float64 da; 282 283 da = long_to_float64(i); 284 return da.d; 277 285 } 278 286 … … 286 294 double __floattidf(long long i) 287 295 { 296 float64 da; 297 298 da = longlong_to_float64(i); 299 return da.d; 288 300 } 289 301 … … 297 309 double __floatunsidf(unsigned int i) 298 310 { 311 float64 da; 312 313 da = uint_to_float64(i); 314 return da.d; 299 315 } 300 316 … … 308 324 double __floatundidf(unsigned long i) 309 325 { 326 float64 da; 327 328 da = ulong_to_float64(i); 329 return da.d; 310 330 } 311 331 … … 319 339 double __floatuntidf(unsigned long long i) 320 340 { 341 float64 da; 342 343 da = ulonglong_to_float64(i); 344 return da.d; 321 345 } 322 346 -
softfloat/include/conversion.h
rba5870d rf37d769 51 51 float32 uint64_to_float32(__u64 i); 52 52 float32 int64_to_float32(__s64 i); 53 54 float64 uint32_to_float64(__u32 i); 55 float64 int32_to_float64(__s32 i); 56 57 float64 uint64_to_float64(__u64 i); 58 float64 int64_to_float64(__s64 i); 59 53 60 #endif 54 61
Note:
See TracChangeset
for help on using the changeset viewer.