Changeset aa59fa0 in mainline for softfloat/generic/conversion.c
- Timestamp:
- 2006-03-16T00:32:41Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 585819d
- Parents:
- 69cdeec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
softfloat/generic/conversion.c
r69cdeec raa59fa0 35 35 { 36 36 float64 result; 37 __u64frac;37 uint64_t frac; 38 38 39 39 result.parts.sign = a.parts.sign; … … 74 74 { 75 75 float32 result; 76 __s32exp;77 __u64frac;76 int32_t exp; 77 uint64_t frac; 78 78 79 79 result.parts.sign = a.parts.sign; … … 84 84 85 85 if (isFloat64SigNaN(a)) { 86 result.parts.fraction = 0x 800000; /* set first bit of fraction nonzero */86 result.parts.fraction = 0x400000; /* set first bit of fraction nonzero */ 87 87 return result; 88 88 } … … 145 145 * @return unsigned integer 146 146 */ 147 static __u32_float32_to_uint32_helper(float32 a)148 { 149 __u32frac;147 static uint32_t _float32_to_uint32_helper(float32 a) 148 { 149 uint32_t frac; 150 150 151 151 if (a.parts.exp < FLOAT32_BIAS) { … … 173 173 * - now its the biggest or the smallest int 174 174 */ 175 __u32float32_to_uint32(float32 a)175 uint32_t float32_to_uint32(float32 a) 176 176 { 177 177 if (isFloat32NaN(a)) { … … 193 193 * - now its the biggest or the smallest int 194 194 */ 195 __s32float32_to_int32(float32 a)195 int32_t float32_to_int32(float32 a) 196 196 { 197 197 if (isFloat32NaN(a)) { … … 213 213 * @return unsigned integer 214 214 */ 215 static __u64_float64_to_uint64_helper(float64 a)216 { 217 __u64frac;215 static uint64_t _float64_to_uint64_helper(float64 a) 216 { 217 uint64_t frac; 218 218 219 219 if (a.parts.exp < FLOAT64_BIAS) { … … 241 241 * - now its the biggest or the smallest int 242 242 */ 243 __u64float64_to_uint64(float64 a)243 uint64_t float64_to_uint64(float64 a) 244 244 { 245 245 if (isFloat64NaN(a)) { … … 261 261 * - now its the biggest or the smallest int 262 262 */ 263 __s64float64_to_int64(float64 a)263 int64_t float64_to_int64(float64 a) 264 264 { 265 265 if (isFloat64NaN(a)) { … … 284 284 * @return unsigned integer 285 285 */ 286 static __u64_float32_to_uint64_helper(float32 a)287 { 288 __u64frac;286 static uint64_t _float32_to_uint64_helper(float32 a) 287 { 288 uint64_t frac; 289 289 290 290 if (a.parts.exp < FLOAT32_BIAS) { … … 312 312 * - now its the biggest or the smallest int 313 313 */ 314 __u64float32_to_uint64(float32 a)314 uint64_t float32_to_uint64(float32 a) 315 315 { 316 316 if (isFloat32NaN(a)) { … … 332 332 * - now its the biggest or the smallest int 333 333 */ 334 __s64float32_to_int64(float32 a)334 int64_t float32_to_int64(float32 a) 335 335 { 336 336 if (isFloat32NaN(a)) { … … 352 352 * - now its the biggest or the smallest int 353 353 */ 354 __u32float64_to_uint32(float64 a)354 uint32_t float64_to_uint32(float64 a) 355 355 { 356 356 if (isFloat64NaN(a)) { … … 365 365 } 366 366 367 return ( __u32)_float64_to_uint64_helper(a);367 return (uint32_t)_float64_to_uint64_helper(a); 368 368 } 369 369 … … 372 372 * - now its the biggest or the smallest int 373 373 */ 374 __s32float64_to_int32(float64 a)374 int32_t float64_to_int32(float64 a) 375 375 { 376 376 if (isFloat64NaN(a)) { … … 384 384 return MAX_INT32; 385 385 } 386 return ( __s32)_float64_to_uint64_helper(a);386 return (int32_t)_float64_to_uint64_helper(a); 387 387 } 388 388 … … 391 391 * 392 392 */ 393 float32 uint32_to_float32( __u32i)393 float32 uint32_to_float32(uint32_t i) 394 394 { 395 395 int counter; 396 __s32exp;396 int32_t exp; 397 397 float32 result; 398 398 … … 423 423 } 424 424 425 float32 int32_to_float32( __s32i)425 float32 int32_to_float32(int32_t i) 426 426 { 427 427 float32 result; 428 428 429 429 if (i < 0) { 430 result = uint32_to_float32(( __u32)(-i));431 } else { 432 result = uint32_to_float32(( __u32)i);430 result = uint32_to_float32((uint32_t)(-i)); 431 } else { 432 result = uint32_to_float32((uint32_t)i); 433 433 } 434 434 … … 439 439 440 440 441 float32 uint64_to_float32( __u64i)441 float32 uint64_to_float32(uint64_t i) 442 442 { 443 443 int counter; 444 __s32 exp; 444 int32_t exp; 445 int32_t j; 445 446 float32 result; 446 447 … … 463 464 i >>= 1 + 32 - counter; 464 465 } 465 466 roundFloat32(&exp, &i); 467 468 result.parts.fraction = i >> 7; 466 467 j = (uint32_t)i; 468 roundFloat32(&exp, &j); 469 470 result.parts.fraction = j >> 7; 469 471 result.parts.exp = exp; 470 472 return result; 471 473 } 472 474 473 float32 int64_to_float32( __s64i)475 float32 int64_to_float32(int64_t i) 474 476 { 475 477 float32 result; 476 478 477 479 if (i < 0) { 478 result = uint64_to_float32(( __u64)(-i));479 } else { 480 result = uint64_to_float32(( __u64)i);480 result = uint64_to_float32((uint64_t)(-i)); 481 } else { 482 result = uint64_to_float32((uint64_t)i); 481 483 } 482 484 … … 490 492 * 491 493 */ 492 float64 uint32_to_float64( __u32i)494 float64 uint32_to_float64(uint32_t i) 493 495 { 494 496 int counter; 495 __s32exp;497 int32_t exp; 496 498 float64 result; 497 __u64frac;499 uint64_t frac; 498 500 499 501 result.parts.sign = 0; … … 520 522 } 521 523 522 float64 int32_to_float64( __s32i)524 float64 int32_to_float64(int32_t i) 523 525 { 524 526 float64 result; 525 527 526 528 if (i < 0) { 527 result = uint32_to_float64(( __u32)(-i));528 } else { 529 result = uint32_to_float64(( __u32)i);529 result = uint32_to_float64((uint32_t)(-i)); 530 } else { 531 result = uint32_to_float64((uint32_t)i); 530 532 } 531 533 … … 536 538 537 539 538 float64 uint64_to_float64( __u64i)540 float64 uint64_to_float64(uint64_t i) 539 541 { 540 542 int counter; 541 __s32exp;543 int32_t exp; 542 544 float64 result; 543 545 … … 567 569 } 568 570 569 float64 int64_to_float64( __s64i)571 float64 int64_to_float64(int64_t i) 570 572 { 571 573 float64 result; 572 574 573 575 if (i < 0) { 574 result = uint64_to_float64(( __u64)(-i));575 } else { 576 result = uint64_to_float64(( __u64)i);576 result = uint64_to_float64((uint64_t)(-i)); 577 } else { 578 result = uint64_to_float64((uint64_t)i); 577 579 } 578 580
Note:
See TracChangeset
for help on using the changeset viewer.