public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "s.cecilio at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/49048] setprecision rounding fails in some cases
Date: Thu, 19 May 2011 17:22:00 -0000	[thread overview]
Message-ID: <bug-49048-4-KZvexsb9Ol@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49048-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Cecilio <s.cecilio at gmail dot com> 2011-05-19 17:01:15 UTC ---
Thanks again, Paolo and Jackub, for your help and explanations. Believe it or
not, I a have a PhD and had to learn a lot of complex mathematics, but I never
heard about so many types of 'rounding' methods. To me, rounding had always
meant round-half-up (banker's rounding): 5.5 rounds up to 6 and 6.5 rounds up
to 7. As this is also the normally required method for financial calculations,
I can not understand the usefulness of printf sometimes rounding up and others
rounding down, as it is the behaviour of round-half-even method. But once I've
learn that (thanks for this) I know that I can no longer rely on setprecision
or printf, and that I have to implement my rounding methods to get the banker's
rounding behaviour. 

I'm wondering how many financial programs are there relying on setprecision
without having noticed its 'problematic' rounding behaviour, caused by printf
and blessed by ISO c++ standard. ;-)

It's been a pleasure taking to both and learning with your help. 
With my best regards,
Cecilio


      parent reply	other threads:[~2011-05-19 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18 17:49 [Bug libstdc++/49048] New: " s.cecilio at gmail dot com
2011-05-18 18:26 ` [Bug libstdc++/49048] " paolo.carlini at oracle dot com
2011-05-18 20:43 ` s.cecilio at gmail dot com
2011-05-18 21:09 ` paolo.carlini at oracle dot com
2011-05-19  6:22 ` s.cecilio at gmail dot com
2011-05-19  6:51 ` jakub at gcc dot gnu.org
2011-05-19  7:53 ` s.cecilio at gmail dot com
2011-05-19  9:00 ` paolo.carlini at oracle dot com
2011-05-19 17:22 ` s.cecilio at gmail dot com [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49048-4-KZvexsb9Ol@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).