This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bug(?) in double(int(x))-...


Hello,

I think I discovered a bug in my egcs version
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)

Please try to compile the following short program,

#include <iostream.h>

double Floor(double x) {
  return (double(int((x)+1000.0)-1000));
}

double Sign(double x) {
  // Does not work with egcs
  return 1.0-2.0*(double(int(x))-Floor(x));
  // but this is a work around
//   double g = double(int(x));
//   return 1.0-2.0*(g-Floor(x));
}

void main() {
  cout << Sign(1.5) << "," << Sign(-1.5) << endl;
}

It only compile with the work around above.

Burkhard

===============================================================================
Burkhard Militzer                                     phone:    +1-217-244-3148
NCSA - University of Illinois                         FAX:      +1-217-244-2909
4009 Beckman Institute                                E-mail: militzer@uiuc.edu
405 N Mathews Ave                                       
Urbana-Champaign,                   
IL 61801, USA          http://www.ncsa.uiuc.edu/Apps/CMP/militzer/research.html



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]