This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
- From: "gdr at integrable-solutions dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jan 2006 12:50:39 -0000
- Subject: [Bug libstdc++/26020] std::advance() isn't stable for floating point numbers
- References: <bug-26020-8082@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #13 from gdr at integrable-solutions dot net 2006-01-30 12:50 -------
Subject: Re: std::advance() isn't stable for floating point numbers
"Woebbeking at web dot de" <gcc-bugzilla@gcc.gnu.org> writes:
| Subject: Re: std::advance() isn't stable for floating point numbers
|
| On Monday 30 January 2006 08:54, gdr at integrable-solutions dot net
| wrote:
| > ------- Comment #11 from gdr at integrable-solutions dot net
|
| > | FYI, I suggested tests for > 0 and < 0 as MSVC 7.1 does it that
| > | way.
| > |
| > | If you convert Distance to difference_type the question is what
| > | happens if Distance is i.e. 0.2. Do you advance by 0 or 1 position?
| >
| > does not that follow from the conversion rule?
|
| Of course. I meant what should it do. Do you want it to advance by 0 or
| 1 position? Do we just use a simple cast or do we need to do some
| rounding? AFAIK MSVC advance by 1 in this case.
Given that Distance is supposed to behave "like" en integral type in
the first place, I would simply use:
(1) implicit conversion to convert it to difference_type;
(2) advance the number of time computed from (1).
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26020