public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/13734] New: round()  gives random numbers
@ 2004-01-19  4:17 unruh at physics dot ubc dot ca
  2004-01-19  4:26 ` [Bug c/13734] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: unruh at physics dot ubc dot ca @ 2004-01-19  4:17 UTC (permalink / raw)
  To: gcc-bugs

The round() function outputs random numbers

#include <math.h>
main()
{
printf( "%f %f\n", round(1.0), round(1.0001));
}

Output
-2.000000 6.000000

However these values appear to be random, and can change on different 
machines and at different times on the same machine.

(Mandrake 9.0 and 9.1)
gcc -o test test.c -lm

-- 
           Summary: round()  gives random numbers
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: unruh at physics dot ubc dot ca
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c/13734] round()  gives random numbers
  2004-01-19  4:17 [Bug c/13734] New: round() gives random numbers unruh at physics dot ubc dot ca
@ 2004-01-19  4:26 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-19  4:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-19 04:26 -------
Use warnings:
pr13734.c:4: warning: return type defaults to `int'
pr13734.c: In function `main':
pr13734.c:5: warning: implicit declaration of function `round'
pr13734.c:5: warning: double format, different type arg (arg 2)
pr13734.c:5: warning: double format, different type arg (arg 3)
pr13734.c:6: warning: control reaches end of non-void function

See how round is implicitly declared, use -std=c99 or -std=gnu99 which turns on the c99 
functions in math.h.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19  4:17 [Bug c/13734] New: round() gives random numbers unruh at physics dot ubc dot ca
2004-01-19  4:26 ` [Bug c/13734] " pinskia at gcc dot gnu dot 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).