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(-57, -70).PHP_EOL); echo(calculateAccuracy(-58, -70).PHP_EOL); echo(calculateAccuracy(-59, -70).PHP_EOL); echo(calculateAccuracy(-60, -70).PHP_EOL); echo(calculateAccuracy(-61, -70).PHP_EOL); echo(calculateAccuracy(-62, -70).PHP_EOL); echo(calculateAccuracy(-64, -70).PHP_EOL); echo(calculateAccuracy(-66, -70).PHP_EOL); echo(calculateAccuracy(-68, -70).PHP_EOL); echo(calculateAccuracy(-70, -70).PHP_EOL);
based on oYaiT
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
5.886423916356 4.496234496331 3.9459694200863 3.4724483138895 3.0639286725642 2.7106187374929 2.4043286226271 1.9064177407785 1.5272373723186 1.23607780992 1.01076
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/u3USn on line 18 5.886423916356PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 19 4.496234496331PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 20 3.9459694200863PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 21 3.4724483138895PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 22 3.0639286725642PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 23 2.7106187374929PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 24 2.4043286226271PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 25 1.9064177407785PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 26 1.5272373723186PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 27 1.23607780992PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u3USn on line 28 1.01076PHP_EOL