Changeset 1d83419 in mainline for softfloat/generic/conversion.c
- Timestamp:
- 2006-02-24T17:27:19Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ba5870d
- Parents:
- a82695c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
softfloat/generic/conversion.c
ra82695c r1d83419 30 30 #include "conversion.h" 31 31 #include "comparison.h" 32 #include "common.h" 32 33 33 34 float64 convertFloat32ToFloat64(float32 a) … … 386 387 } 387 388 388 389 390 /** Convert unsigned integer to float32 391 * 392 * 393 */ 394 float32 uint32_to_float32(__u32 i) 395 { 396 int counter; 397 __s32 exp; 398 float32 result; 399 400 result.parts.sign = 0; 401 result.parts.fraction = 0; 402 403 counter = countZeroes32(i); 404 405 exp = FLOAT32_BIAS + 32 - counter - 1; 406 407 if (counter == 32) { 408 result.binary = 0; 409 return result; 410 } 411 412 if (counter > 0) { 413 i <<= counter - 1; 414 } else { 415 i >>= 1; 416 } 417 418 roundFloat32(&exp, &i); 419 420 result.parts.fraction = i >> 7; 421 result.parts.exp = exp; 422 423 return result; 424 } 425 426 float32 int32_to_float32(__s32 i) 427 { 428 float32 result; 429 430 if (i < 0) { 431 result = uint32_to_float32((__u32)(-i)); 432 } else { 433 result = uint32_to_float32((__u32)i); 434 } 435 436 result.parts.sign = i < 0; 437 438 return result; 439 } 440 441 442 float32 uint64_to_float32(__u64 i) 443 { 444 } 445 446 float32 int64_to_float32(__s64 i) 447 { 448 float32 result; 449 450 if (i < 0) { 451 result = uint64_to_float32((__u64)(-i)); 452 } else { 453 result = uint64_to_float32((__u64)i); 454 } 455 456 result.parts.sign = i < 0; 457 458 return result; 459 }
Note:
See TracChangeset
for help on using the changeset viewer.