public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64808] New: static_cast double to int on linux 32
@ 2015-01-26 18:37 friend1992friend1992 at yandex dot ru
2015-01-26 18:40 ` [Bug c++/64808] " friend1992friend1992 at yandex dot ru
2015-01-26 19:04 ` schwab@linux-m68k.org
0 siblings, 2 replies; 3+ messages in thread
From: friend1992friend1992 at yandex dot ru @ 2015-01-26 18:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64808
Bug ID: 64808
Summary: static_cast double to int on linux 32
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: friend1992friend1992 at yandex dot ru
I have code :
#include <iostream>
void fun(double _v)
{
std::cout<<"_v="<<_v<<std::endl;
long long int var=static_cast< long long int >(_v*1000.);
std::cout<<"var="<<var<<std::endl;
}
int main(int ac, char** av)
{
fun(33.33);
return 0;
}
I try to compile this code on Linux x86_64 with GCC 4.8.2 (g++ test.cpp -o
test64), I get result in console:
_v=33.33
var=33330
but when I try to compile this code on Linux i686 with GCC 4.8.2 (g++ test.cpp
-o test32), I get result in console:
_v=33.33
var=33329
But if I replace "long long int var=static_cast< long long int >(_v*1000.);" to
"double t = _v*1000.; long int var=static_cast< long long int >(t);" I get the
result on Linux i686 with GCC 4.4.5:
_v=33.33
var=33330
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/64808] static_cast double to int on linux 32
2015-01-26 18:37 [Bug c++/64808] New: static_cast double to int on linux 32 friend1992friend1992 at yandex dot ru
@ 2015-01-26 18:40 ` friend1992friend1992 at yandex dot ru
2015-01-26 19:04 ` schwab@linux-m68k.org
1 sibling, 0 replies; 3+ messages in thread
From: friend1992friend1992 at yandex dot ru @ 2015-01-26 18:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64808
--- Comment #1 from friend1992friend1992 at yandex dot ru ---
> get the result on Linux i686 with GCC 4.4.5:
Sorry, GCC 4.8.2:
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/64808] static_cast double to int on linux 32
2015-01-26 18:37 [Bug c++/64808] New: static_cast double to int on linux 32 friend1992friend1992 at yandex dot ru
2015-01-26 18:40 ` [Bug c++/64808] " friend1992friend1992 at yandex dot ru
@ 2015-01-26 19:04 ` schwab@linux-m68k.org
1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2015-01-26 19:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64808
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
You see the effect of excess precision of a floating point value that cannot be
represented exactly.
*** This bug has been marked as a duplicate of bug 323 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-26 19:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-26 18:37 [Bug c++/64808] New: static_cast double to int on linux 32 friend1992friend1992 at yandex dot ru
2015-01-26 18:40 ` [Bug c++/64808] " friend1992friend1992 at yandex dot ru
2015-01-26 19:04 ` schwab@linux-m68k.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).