[test] floating point comparison
Hello,
Can someone please tell me exactly what do I need to include and which
namespace to use to get exact same behavior as:
#include
Emil Dotchevski
Hello,
Can someone please tell me exactly what do I need to include and which namespace to use to get exact same behavior as:
#include
bool check( float a, float b, float tolerance ) { using namespace boost::test_tools; return check_is_close(a,b,fraction_tolerance(tolerance)); }
(The above used to work with older Boost versions but no longer.)
Do you refer to the develop branch? BOOST_TEST(a==b, tolerance); should do the same. Or BOOST_TEST(a==b); if tolerance is set for test case. Gennadiy
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental Sent: 26 April 2015 08:14 To: boost@lists.boost.org Subject: Re: [boost] [test] floating point comparison
Emil Dotchevski
writes: Hello,
Can someone please tell me exactly what do I need to include and which namespace to use to get exact same behavior as:
#include
bool check( float a, float b, float tolerance ) { using namespace boost::test_tools; return check_is_close(a,b,fraction_tolerance(tolerance)); }
(The above used to work with older Boost versions but no longer.)
Do you refer to the develop branch?
BOOST_TEST(a==b, tolerance);
should do the same. Or
BOOST_TEST(a==b);
if tolerance is set for test case.
As I have explained before, most recently about check_is_close, users would clearly like to use the
code in
#include
Paul A. Bristow
#include
outside Boost.Test.
I have put some time into providing documentation to go in Boost.Math that demonstrate and explain how this can be done.
It would be *really unhelpful* to remove this facility.
Boost.Test does not need these shortcuts anymore. These never really been part of public API. If you find these convenient we can keep them. Gennadiy
On Sun, Apr 26, 2015 at 12:14 AM, Gennadiy Rozental
Emil Dotchevski
writes: Hello,
Can someone please tell me exactly what do I need to include and which namespace to use to get exact same behavior as:
#include
bool check( float a, float b, float tolerance ) { using namespace boost::test_tools; return check_is_close(a,b,fraction_tolerance(tolerance)); }
(The above used to work with older Boost versions but no longer.)
Do you refer to the develop branch?
BOOST_TEST(a==b, tolerance);
should do the same.
Yes, sorry -- I mean the development branch. Could you provide a replacement for the function above? Note that it returns a value, which isn't the same as BOOST_TEST. Also please indicate what headers need to be included. Emil
Le 26/04/15 22:22, Emil Dotchevski a écrit :
On Sun, Apr 26, 2015 at 12:14 AM, Gennadiy Rozental
wrote: Emil Dotchevski
writes: Hello,
Can someone please tell me exactly what do I need to include and which namespace to use to get exact same behavior as:
#include
bool check( float a, float b, float tolerance ) { using namespace boost::test_tools; return check_is_close(a,b,fraction_tolerance(tolerance)); }
(The above used to work with older Boost versions but no longer.)
Do you refer to the develop branch?
BOOST_TEST(a==b, tolerance);
should do the same.
Yes, sorry -- I mean the development branch.
Could you provide a replacement for the function above? Note that it returns a value, which isn't the same as BOOST_TEST. Also please indicate what headers need to be included.
Emil
Hi Emil, The corresponding documentation has been updated recently: http://www.boost.org/doc/libs/develop/libs/test/doc/html/boost_test/users_gu... and http://www.boost.org/doc/libs/develop/libs/test/doc/html/boost/math/fpc/clos... Those pages indicate the required headers and namespaces. BOOST_TEST is using this predicate, so would you please give me some more info about "Note that it returns a value, which isn't the same as BOOST_TEST"? The corresponding equivalent code should be bool check( float a, float b, float tolerance ) { using namespace boost::math::fpc; close_at_tolerance obj(tolerance); return obj(a,b); } Best, Raffi
On Mon, Apr 27, 2015 at 7:23 PM, Gennadiy Rozental
Raffi Enficiaud
writes: The corresponding equivalent code should be
bool check( float a, float b, float tolerance ) { using namespace boost::math::fpc; close_at_tolerance obj(tolerance);
close_at_tolerance<float> obj(tolerance);
return obj(a,b); }
With
#include
On Mon, Apr 27, 2015 at 9:42 PM, Emil Dotchevski
With
#include
bool check( float a, float b, float tolerance ) { using namespace boost::math::fpc; close_at_tolerance<float> obj(tolerance); obj(a,b); }
I get "type 'float' unexpected".
Please disregard the above. Thanks! Emil
participants (5)
-
Emil Dotchevski
-
Emil Dotchevski
-
Gennadiy Rozental
-
Paul A. Bristow
-
Raffi Enficiaud