comparison gcc/config/dfp-bit.c @ 36:855418dad1a3

gcc-4.4-20091020
author e075725
date Tue, 22 Dec 2009 21:19:31 +0900
parents a06113de4d67
children
comparison
equal deleted inserted replaced
19:58ad6c70ea60 36:855418dad1a3
566 union { _Decimal32 c; decSingle f; } u32; 566 union { _Decimal32 c; decSingle f; } u32;
567 decDouble f64; 567 decDouble f64;
568 decContext context; 568 decContext context;
569 569
570 decContextDefault (&context, DEC_INIT_DECIMAL128); 570 decContextDefault (&context, DEC_INIT_DECIMAL128);
571 context.round = DEC_ROUND_DOWN;
572 f64 = *DEC_FLOAT_FROM_INT (&f64, i); 571 f64 = *DEC_FLOAT_FROM_INT (&f64, i);
573 u32.f = *decSingleFromWider (&u32.f, &f64, &context); 572 u32.f = *decSingleFromWider (&u32.f, &f64, &context);
574 if (DFP_EXCEPTIONS_ENABLED && context.status != 0) 573 if (DFP_EXCEPTIONS_ENABLED && context.status != 0)
575 dfp_conversion_exceptions (context.status); 574 dfp_conversion_exceptions (context.status);
576 return u32.c; 575 return u32.c;
591 590
592 decContextDefault (&context, CONTEXT_INIT); 591 decContextDefault (&context, CONTEXT_INIT);
593 DFP_INIT_ROUNDMODE (context.round); 592 DFP_INIT_ROUNDMODE (context.round);
594 593
595 /* Use a C library function to get a floating point string. */ 594 /* Use a C library function to get a floating point string. */
596 sprintf (buf, INT_FMT ".0", CAST_FOR_FMT(i)); 595 sprintf (buf, INT_FMT ".", CAST_FOR_FMT(i));
597 /* Convert from the floating point string to a decimal* type. */ 596 /* Convert from the floating point string to a decimal* type. */
598 FROM_STRING (&s, buf, &context); 597 FROM_STRING (&s, buf, &context);
599 IEEE_TO_HOST (s, &f); 598 IEEE_TO_HOST (s, &f);
600 599
601 if (DFP_EXCEPTIONS_ENABLED && context.status != 0) 600 if (DFP_EXCEPTIONS_ENABLED && context.status != 0)