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

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

Build:
Build:
LAST BUILD BRANCH: double_comparison_corrections
DEFAULT BRANCH: master
Ran 02 Nov 2017 02:56AM 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
61

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 61.1 (CGREEN_WITH_STATIC_LIBRARY="OFF") 02 Nov 2017 02:56AM UTC 0
96.2
Travis Job 61.1
2 61.2 (CGREEN_WITH_STATIC_LIBRARY="ON") 02 Nov 2017 03:01AM UTC 0
96.2
Travis Job 61.2
Source Files on build 61
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #61
  • 5b40aa6a on github
  • Prev Build on double_comparison_corrections (#60)
  • Next Build on double_comparison_corrections (#62)
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