public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51559] New: decimal128 operates incorrectly compared to decimal32 and decimal64
@ 2011-12-14 22:56 mingodad at gmail dot com
2011-12-14 23:46 ` [Bug c++/51559] " mingodad at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: mingodad at gmail dot com @ 2011-12-14 22:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51559
Bug #: 51559
Summary: decimal128 operates incorrectly compared to decimal32
and decimal64
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: mingodad@gmail.com
Created attachment 26092
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26092
Program that demostrates decimal128 fault
Testing the new decimal classes on g++ mingw4.6.1.2 with this program the
decimal32 and decimal64 are showing the expected answer but decimal128 doesn't
all parameters are equal but the result not.
With all 3 decimal classes three instances are created with the following
values:
std::decimal::decimal* dn(.3), dn2(.099), dn3(1000), dn4(201);
dn-=dn2;
dn*=dn3;
cout << "decimal* = " << (dn==dn4) << " : " << decimal*_to_double(dn) << endl;
Expects "dn==dn4" on all but decimal128 fails.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/51559] decimal128 operates incorrectly compared to decimal32 and decimal64
2011-12-14 22:56 [Bug c++/51559] New: decimal128 operates incorrectly compared to decimal32 and decimal64 mingodad at gmail dot com
@ 2011-12-14 23:46 ` mingodad at gmail dot com
2011-12-15 9:44 ` mingodad at gmail dot com
2013-08-15 13:59 ` kubry at terra dot com
2 siblings, 0 replies; 4+ messages in thread
From: mingodad at gmail dot com @ 2011-12-14 23:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51559
--- Comment #1 from Domingo Alvarez <mingodad at gmail dot com> 2011-12-14 23:41:16 UTC ---
Created attachment 26094
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26094
A c program that demonstrate the same problem
Here is a c program that exibits the same problem, so it's not a c++ only
problem probably it's an intrinsic implementation fault of decimal128.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/51559] decimal128 operates incorrectly compared to decimal32 and decimal64
2011-12-14 22:56 [Bug c++/51559] New: decimal128 operates incorrectly compared to decimal32 and decimal64 mingodad at gmail dot com
2011-12-14 23:46 ` [Bug c++/51559] " mingodad at gmail dot com
@ 2011-12-15 9:44 ` mingodad at gmail dot com
2013-08-15 13:59 ` kubry at terra dot com
2 siblings, 0 replies; 4+ messages in thread
From: mingodad at gmail dot com @ 2011-12-15 9:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51559
Domingo Alvarez <mingodad at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #2 from Domingo Alvarez <mingodad at gmail dot com> 2011-12-15 09:40:35 UTC ---
Doing more tests I discovered that the problem is inherent to using floating
points to initialize decimal128, doing it step by step with integer
initialization gives the expected result.
decimal128 d10(10), d1000(1000), d3(3), d99(99), d201(201);
d3 /= d10); //d3 = 0.3
d99 /= d1000; //d99 = 0.099
d3 -= d99; //d3 = 0.201
d3 *= d1000; // d3 = 201
now d3 == d201
Sorry by the false bug report.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/51559] decimal128 operates incorrectly compared to decimal32 and decimal64
2011-12-14 22:56 [Bug c++/51559] New: decimal128 operates incorrectly compared to decimal32 and decimal64 mingodad at gmail dot com
2011-12-14 23:46 ` [Bug c++/51559] " mingodad at gmail dot com
2011-12-15 9:44 ` mingodad at gmail dot com
@ 2013-08-15 13:59 ` kubry at terra dot com
2 siblings, 0 replies; 4+ messages in thread
From: kubry at terra dot com @ 2013-08-15 13:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51559
Ganton <kubry at terra dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kubry at terra dot com
--- Comment #3 from Ganton <kubry at terra dot com> ---
> The problem is inherent to using floating points to initialize decimal128
Instead of:
- Using a floating point to initialize a decimal128.
- Dividing integers to initialize a decimal128.
people can use a decimal number to initialize a decimal128.
In the prior examples, instead of
std::decimal::decimal128 dn(.3), dn2(.099), dn3(1000), dn4(201);
people can use
std::decimal::decimal128 dn(.3dl), dn2(.099dl), dn3(1000), dn4(201);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-15 13:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-14 22:56 [Bug c++/51559] New: decimal128 operates incorrectly compared to decimal32 and decimal64 mingodad at gmail dot com
2011-12-14 23:46 ` [Bug c++/51559] " mingodad at gmail dot com
2011-12-15 9:44 ` mingodad at gmail dot com
2013-08-15 13:59 ` kubry at terra dot com
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).