Boost logo

Boost :

From: Arash Partow (arash_at_[hidden])
Date: 2007-05-16 05:20:50

Hi Jody,

This may be a little off-topic but I believe it may help you
better understand what these discrepancies are that you are
seeing. Assume you have the following fractions:

1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024, etc...

You are then asked to select a group of these fractions such that
their sum is 0.1, but you are told that there is a limit on the size
of the group, for instance you can't use more than 6 fractions in
the group (you can use any amount of them just no more than 6),

Now the questions:

1. How close could you get to 0.1?

2. Could you represent 0.1 exactly?

3. From all the combinations that you could come up with,
what would be the closest value to 0.1 you could come up with?

Arash Partow
Be one who knows what they don't know,
Instead of being one who knows not what they don't know,
Thinking they know everything about all things.

Jody Hagins wrote:
> OK, here is an opportunity to get me clear on comparing floating point
> values. I've found a very simple example, that I can not get to work --
> and understand...
> Say I have a class that saves and restores a class. In the class, I
> have a double, a float, and a long double. As a test, I set the
> "floating" values to std::numeric_limits< T >::min() and
> std::numeric_limits< T >::max(), and then save the values, restore them,
> and compare the restored values to the originals.
> Obviously, I can not use BOOST_CHECK_EQUAL(), but I am clueless as to
> how to use the macros for comparing floating point values. Is there
> anything in numeric_limits that I should use to base the percentage
> value?
> Here's a chance for someone to finally clear my understanding of how to
> compare floating point value... please ?!?!?
> Thanks!
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at