Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 569 Bytes

File metadata and controls

19 lines (13 loc) · 569 Bytes

assert_close

Asserts that two numeric values are equal after rounding to a decimal precision.

The default precision is 2 decimal digits. Integral values are compared exactly. Boolean values are rejected because closeness is a numeric relation, not a truth-value relation.

#include <kaycxx/assert.hpp>

using namespace kaycxx::assert;

int main() {
    assert_close(1.234, 1.233);
    assert_close(3.14159, 3.142, 3);
    assert_close(42, 42);
}

Use assert_close for result values where small floating-point differences are acceptable after rounding.