public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39902]  New: x * 1.0DF gets wrong value
@ 2009-04-25 22:32 tydeman at tybor dot com
  2009-06-26 18:28 ` [Bug c/39902] " janis at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: tydeman at tybor dot com @ 2009-04-25 22:32 UTC (permalink / raw)
  To: gcc-bugs

Multiplication by a decimal floating-point (DFP) value of one appears to be
"optimized" away, thereby producing the wrong value.  In DFP, the value one has
many representations.  Only one of them (1.DF) results in no change to values
for multiplication; the others change the quantum exponent.

/* DFP TR 24732 == WG14 / N1312 */
#define __STDC_WANT_DEC_FP__ /* Tell implementation that we want Decimal FP */

#include <stdio.h>      /* printf() */
#include <string.h>     /* memcmp() */

int main(void){
  _Decimal32 f1 = 1.0DF;
  _Decimal32 f2 = 2.0DF;
  _Decimal32 f3;

  f3 = f2 * f1;         /* should change quantum exponent */
  if( 0 == memcmp( &f3, &f2, sizeof(f3) ) ){
    (void)printf("Fail 1\n");
  }

  f3 = f2 * 1.0DF;      /* should change quantum exponent */
  if( 0 == memcmp( &f3, &f2, sizeof(f3) ) ){
    (void)printf("Fail 2\n");
  }
  return 0;
}

gets: Fail 2


-- 
           Summary: x * 1.0DF gets wrong value
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tydeman at tybor dot com
 GCC build triplet: 4.3.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39902


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-39902-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2014-05-06 19:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-25 22:32 [Bug c/39902] New: x * 1.0DF gets wrong value tydeman at tybor dot com
2009-06-26 18:28 ` [Bug c/39902] " janis at gcc dot gnu dot org
2009-06-29 17:13 ` janis at gcc dot gnu dot org
2009-07-30 17:05 ` janis at gcc dot gnu dot org
2009-07-30 17:08 ` janis at gcc dot gnu dot org
2009-08-03 21:39 ` janis at gcc dot gnu dot org
2009-08-03 21:44 ` janis at gcc dot gnu dot org
2009-08-03 21:48 ` janis at gcc dot gnu dot org
2009-08-03 21:49 ` janis at gcc dot gnu dot org
     [not found] <bug-39902-4@http.gcc.gnu.org/bugzilla/>
2014-05-06 19:05 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).