Changeset 666
- Timestamp:
- Jul 27, 2015, 5:56:15 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/stdio.c
r661 r666 350 350 case ('g'): /* IEEE754 64 bits */ 351 351 { 352 353 double vald = va_arg( *args, double); 354 355 unsigned long long 356 val = *(unsigned long long*)&vald, //get ieee754 without conversion 357 digits = val & 0xFFFFFFFFFFFFFULL; //get mantissa 352 union 353 { 354 double d; 355 unsigned long long ull; 356 } val; 357 358 val.d = va_arg( *args, double ); 359 360 unsigned long long digits = val.ull & 0xFFFFFFFFFFFFFULL; //get mantissa 358 361 359 362 unsigned int 360 base = (unsigned int)((val & 0x7FF0000000000000ULL) >> 52), //get exposant361 intp = (unsigned int)val d, //get integer part of the float363 base = (unsigned int)((val.ull & 0x7FF0000000000000ULL) >> 52), //get exposant 364 intp = (unsigned int)val.d, //get integer part of the float 362 365 decp; 363 366 … … 378 381 { 379 382 /* inf */ 380 buf[0] = (val & 0x8000000000000000ULL) ? '-' : '+';383 buf[0] = (val.ull & 0x8000000000000000ULL) ? '-' : '+'; 381 384 buf[1] = 'i'; 382 385 buf[2] = 'n'; … … 388 391 } 389 392 390 if (val & 0x8000000000000000ULL)393 if (val.ull & 0x8000000000000000ULL) 391 394 { 392 395 /* negative */ … … 397 400 0); 398 401 if (ret != 1) goto return_error; 399 val d = vald * -1;402 val.d = val.d * -1; 400 403 } 401 404 else … … 410 413 } 411 414 412 if (val d > 0xFFFFFFFF)415 if (val.d > 0xFFFFFFFF) 413 416 { 414 417 /* overflow */ … … 421 424 } 422 425 423 val d -= (double)intp;424 decp = (unsigned int)(val d * 1000000000);426 val.d -= (double)intp; 427 decp = (unsigned int)(val.d * 1000000000); 425 428 426 429 for(i = 0; i < 10; i++) … … 443 446 if (!isvalue) 444 447 { 445 if (val d != 0)448 if (val.d != 0) 446 449 { 447 450 /* underflow */
Note: See TracChangeset
for help on using the changeset viewer.