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]
Other format: [Raw text]

Re: -0.00


Mohammad Hossein Bateni wrote:
 it writes:  -0.00 instead of 0.00
  double a = -0.0001;
  printf("%0.02lf\n", a);

See http://gcc.gnu.org/bugs.html for info on reporting bugs.


This is a C library issue, not a compiler issue. Since you gave no info about the target, I can not comment further. You could try reporting this to whoever maintains the C library you are using. However, the behaviour seems reasonable to me. printf doesn't do any arithmetic on the value, it just prints how many digits you asked for. The value is negative, and you only asked for two sigificant digits, so -0.00 is what you get.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



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