PHP code example of jstewmc / almost-equals
1. Go to this page and download the library: Download jstewmc/almost-equals library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jstewmc / almost-equals example snippets
namespace Jstewmc\AlmostEquals;
// instantiate the service
$service = new AlmostEquals();
// compare stuff!
$service(1/10, 0.1); // returns true (0.1 === 0.1)
$service(2/10, 0.1); // returns false (0.2 !== 0.1)
namespace Jstewmc\AlmostEquals;
// defaults to an epsilon of 0.00001
$service = new AlmostEquals();
$service(1/10, 0.1); // returns true
$service(0.10002, 0.1); // returns false (0.00002 > 0.00001)
$service(0.100002, 0.1); // returns true (0.000002 < 0.00001)