|
Boost Users : |
Subject: Re: [Boost-users] [lexical_cast] float-to-string rounding error (notfound with cout)
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-04-30 18:53:03
On Thu, Apr 30, 2009 at 1:57 PM, Dominique Devienne <ddevienne_at_[hidden]> wrote:
> [DD] Rarely, not never ;-)
Never for people who do not know how it actually works internally :P
On Thu, Apr 30, 2009 at 1:57 PM, Dominique Devienne <ddevienne_at_[hidden]> wrote:
>> A more proper implementation would be:
>> bool FloatsEqual(float f1, float f2, float eps=0.00001)
>> {
>> return eps>(f1-f2);
>> }
>
> I'm no expert, but the above does not take into account the
> "magnitude" of the numbers.
> Comparing 0.000001 and 0.0000011 with 0.000001
> and 999999.0 and 999999.1 with 0.00001 don't mean the same thing at all.
Which is why eps was a default value that can be overridden with
whatever might be good for the time. And yea, forgot the absolute,
been a long day. :)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net