Package Info

perl-Test-Number-Delta


Compare the difference between numbers against a given tolerance


Development/Libraries/Perl

At some point or another, most programmers find they need to compare floating-point numbers for equality. The typical idiom is to test if the absolute value of the difference of the numbers is within a desired tolerance, usually called epsilon. This module provides such a function for use with the Test::More manpage. Usage is similar to other test functions described in the Test::More manpage. Semantically, the 'delta_within' function replaces this kind of construct:

ok ( abs($p - $q) < $epsilon, '$p is equal to $q' ) or diag "$p is not equal to $q to within $epsilon";

While there's nothing wrong with that construct, it's painful to type it repeatedly in a test script. This module does the same thing with a single function call. The 'delta_ok' function is similar, but either uses a global default value for epsilon or else calculates a 'relative' epsilon on the fly so that epsilon is scaled automatically to the size of the arguments to 'delta_ok'. Both functions are exported automatically.

Because checking floating-point equality is not always reliable, it is not possible to check the 'equal to' boundary of 'less than or equal to epsilon'. Therefore, Test::Number::Delta only compares if the absolute value of the difference is less than epsilon (for equality tests) or greater than epsilon (for inequality tests).


License: Apache-2.0
URL: http://search.cpan.org/dist/Test-Number-Delta/

Categories

Releases

Package Version Update ID Released Package Hub Version Platforms Subpackages
1.060000-bp155.2.10 info GA Release 2023-05-17 15 SP5
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Test-Number-Delta
1.060000-bp154.1.23 info GA Release 2022-05-09 15 SP4
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Test-Number-Delta
1.060000-bp153.1.15 info GA Release 2021-03-06 15 SP3
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Test-Number-Delta
1.060000-bp152.3.16 info GA Release 2020-04-16 15 SP2
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Test-Number-Delta
1.060000-bp151.3.1 info GA Release 2019-07-16 15 SP1
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Test-Number-Delta
1.060000-bp151.2.12 info GA Release 2019-05-18 15 SP1
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Test-Number-Delta
1.060000-bp150.2.4 info GA Release 2018-07-30 15
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Test-Number-Delta