3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function calculateAccuracy($txPower, $rssi){ if ($rssi == 0) { return -1.0; // if we cannot determine accuracy, return -1. } $ratio = $rssi*1.0/$txPower; if ($ratio < 1.0) { return pow($ratio,10); } else { $accuracy = (0.89976)*pow($ratio,7.7095) + 0.111; return $accuracy; } } echo(calculateAccuracy(-55, -70).PHP_EOL); echo(calculateAccuracy(-56, -70).PHP_EOL); echo(calculateAccuracy(-57, -70).PHP_EOL);
based on u3USn
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
5.886423916356 5.1373696851891 4.496234496331
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uM352 on line 18 5.886423916356PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uM352 on line 19 5.1373696851891PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uM352 on line 20 4.496234496331PHP_EOL