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

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

Build:
Build:
LAST BUILD BRANCH: double_comparison_corrections
DEFAULT BRANCH: master
Ran 03 Nov 2017 02:15AM UTC
Files 73
Run time 2s
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

03 Nov 2017 02:08AM UTC coverage: 96.201%. Remained the same
CGREEN_WITH_STATIC_LIBRARY="OFF"

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.

5368 of 5580 relevant lines covered (96.2%)

97052.84 hits per line

Source Files on job 62.1 (CGREEN_WITH_STATIC_LIBRARY="OFF")
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 62
  • Travis Job 62.1
  • 050c9367 on github
  • Prev Job for CGREEN_WITH_STATIC_LIBRARY="OFF" on double_comparison_corrections (#61.1)
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