public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/7923: g++ - inline cast of double to long returns incorrect value
@ 2002-09-15 21:16 Ian.Nowland
  0 siblings, 0 replies; 2+ messages in thread
From: Ian.Nowland @ 2002-09-15 21:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7923
>Category:       c++
>Synopsis:       g++ - inline cast of double to long returns incorrect value
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 15 21:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ian.Nowland@silverbrookresearch.com
>Release:        gcc 3.2 20020818, gcc 2.95
>Organization:
>Environment:
Cygwin and SuSe Linux 7.2 on Intel
>Description:
In both of these environments the following code should print the same value all three times. However the third value is incorrectly printed as 256.

#include <math.h>
#include <iostream>

int main()
{
    double maxLinearValue = 65535.0;
    double ian = maxLinearValue * pow(double(1.0/ 255.0), 1.0);
    long correctLongValue = long(ian);
    long incorrectLongValue = long(maxLinearValue * pow(1.0/ 255.0, 1.0));
    std::cout << "double: " << ian << std::endl;
    std::cout << "correct: " << correctLongValue << std::endl;
    std::cout << "incorrect: " << incorrectLongValue << std::endl;

    return 0;
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/7923: g++ - inline cast of double to long returns incorrect value
@ 2002-09-28  7:34 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2002-09-28  7:34 UTC (permalink / raw)
  To: Ian.Nowland, gcc-bugs, gcc-prs, nobody

Synopsis: g++ - inline cast of double to long returns incorrect value

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sat Sep 28 07:34:12 2002
State-Changed-Why:
    Not a bug.  Check out the page
      http://gcc.gnu.org/bugs.html#nonbugs
    under issue "Problems with floating point computations" for more information.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7923


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

end of thread, other threads:[~2002-09-28 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-15 21:16 c++/7923: g++ - inline cast of double to long returns incorrect value Ian.Nowland
2002-09-28  7:34 lerdsuwa

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