BOOST_TEST_EQ diagnostic for floating point types lacks precision

Open
#89 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
testing

Research direction

Start with the supplied reproducer and read boost/core/lightweight_test.hpp, where BOOST_TEST_EQ produces the diagnostic. Compare its reported values with the high-precision std::cerr output. Done means the diagnostic distinguishes the two floating-point values rather than printing both as 0.0012.

Written by the indexing model from the issue text.

Description

#include <boost/core/lightweight_test.hpp>
#include <limits>

int main()
{
    BOOST_TEST_EQ(0x9.d495182a99318p-13, 0x9.d495182a99308p-13);
    std::cerr.precision(std::numeric_limits<double>::max_digits10);
    std::cerr << 0x9.d495182a99318p-13 << " == " << 0x9.d495182a99308p-13 << '\n';
    return boost::report_errors();
}
prog.cc(5): test '0x9.d495182a99318p-13 == 0x9.d495182a99308p-13' ('0.0012' == '0.0012') failed in function 'int main()'
0.0012000000000000003 == 0.0011999999999999999
Dominant language
C++
Stars
156
Forks
116
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/core

All issues in boostorg/core

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.