• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

d-meiser / cgreen / 62
96%
master: 96%

Build:
Build:
LAST BUILD BRANCH: double_comparison_corrections
DEFAULT BRANCH: master
Ran 03 Nov 2017 02:15AM UTC
Jobs 2
Files 73
Run time 4min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
62

push

travis-ci

d-meiser
Fix double comparisons for small numbers

* Introduce an absolute tolerance.
* Improve implementation of accuracy function to avoid casting and make the
  logic more transparent.
* Add discussion of floating point comparisons to manual.
* Add a test case.
* Minor cosmetic changes (e.g. renamed a test case).
* Remove a test case that compares a small number with 0 because this is
  expected behavior.

Discussion

The introduction of an absolute tolerance fixes the underflow issues near 0. If
two numbers are within the absolute tolerance of one another they are considered
equal and we don't need to evaluate the problematic accuracy function. We choose
an absolute tolerance that is 10^8 times larger than the smallest double number
that can be represented. Eight is the default number of significant digits used
for relative comparisons. This prevents underflow issues when comparing numbers
near zero for the default number of significant digits.

Note that our default cannot prevent underflow if the user increases the number
of significant digits to a value larger than eight. doubles_are_equal will not
crash in this case but it may wrongly report two numbers as equal. The
problematic cases are numbers near zero.

We have added a discussion of our floating point comparison algorithm to the
manual. We point out the problems that can occur when comparing numbers close to
zero and we propose to use constraints of the form

assert_that_double(fabs(x - y), is_less_than_double(abs_tolerance));

in that case.

8 of 8 new or added lines in 2 files covered. (100.0%)

5368 of 5580 relevant lines covered (96.2%)

194457.49 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
11
100.0
src/constraint.c
Jobs
ID Job ID Ran Files Coverage
1 62.1 (CGREEN_WITH_STATIC_LIBRARY="OFF") 03 Nov 2017 02:15AM UTC 0
96.2
Travis Job 62.1
2 62.2 (CGREEN_WITH_STATIC_LIBRARY="ON") 03 Nov 2017 02:19AM UTC 0
96.2
Travis Job 62.2
Source Files on build 62
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #62
  • 050c9367 on github
  • Prev Build on double_comparison_corrections (#61)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc