gcc 4.0.3 double math/conversion error

Bug #128732 reported by Ben Bridgwater
2
Affects Status Importance Assigned to Milestone
gcc-defaults (Ubuntu)
Fix Released
Undecided
Matthias Klose

Bug Description

Binary package hint: gcc

Running gcc (4.0.3) from Ubuntu 6.10 on a Pentium 4:

double d = 10.1;
int i = (int) (d * 10); // = 100

double t = d * 10;
int j = (int) t; // = 101

I would expect to get the same result (whatever it may be) in both cases.

To reproduce:

#include <stdio.h>

int main()
{
  float f = 10.1;
  double d = 10.1;

  double t;

  printf("%i %i %i\n", (int) (f * 10), (int) (d * 10), (int) (t = (d * 10)));

  // gcc 4.0.3 (Ubuntu 6.10) output is: 101 100 101

}

gcc test.c

a.out

Revision history for this message
Matthias Klose (doko) wrote :

fixed in edgy and newer releases; (gcc-4.1 and gcc-4.2)

Changed in gcc-defaults:
assignee: nobody → doko
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.