public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* -0.00
@ 2004-01-01 12:14 Mohammad Hossein Bateni
  2004-01-06 19:43 ` -0.00 Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Mohammad Hossein Bateni @ 2004-01-01 12:14 UTC (permalink / raw)
  To: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

Hi,
 I have compiled the "test.c" program using command line:
   gcc test.c
 it writes:  -0.00 instead of 0.00
thank you

-- 
http://www.fastmail.fm - Consolidate POP email and Hotmail in one place

[-- Attachment #2: bug-report --]
[-- Type: application/unknown, Size: 1703 bytes --]

[-- Attachment #3: test.c --]
[-- Type: text/plain, Size: 96 bytes --]

#include <stdio.h>

int main() {
  double a = -0.0001;
  printf("%0.02lf\n", a);
  return 0;
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: -0.00
  2004-01-01 12:14 -0.00 Mohammad Hossein Bateni
@ 2004-01-06 19:43 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2004-01-06 19:43 UTC (permalink / raw)
  To: Mohammad Hossein Bateni; +Cc: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-06 19:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-01 12:14 -0.00 Mohammad Hossein Bateni
2004-01-06 19:43 ` -0.00 Jim Wilson

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).