3v4l.org

run code in 300+ PHP versions simultaneously
<?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(-100, -70)); echo(calculateAccuracy(-120, -70)); echo(calculateAccuracy(-140, -70)); echo(calculateAccuracy(-160, -70)); echo(calculateAccuracy(-180, -70)); echo(calculateAccuracy(-200, -70)); echo(calculateAccuracy(-220, -70));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VVY1l
function name:  (null)
number of ops:  36
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'calculateaccuracy'
          1        SEND_VAL                                                 -100
          2        SEND_VAL                                                 -70
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   19     5        INIT_FCALL                                               'calculateaccuracy'
          6        SEND_VAL                                                 -120
          7        SEND_VAL                                                 -70
          8        DO_FCALL                                      0  $1      
          9        ECHO                                                     $1
   20    10        INIT_FCALL                                               'calculateaccuracy'
         11        SEND_VAL                                                 -140
         12        SEND_VAL                                                 -70
         13        DO_FCALL                                      0  $2      
         14        ECHO                                                     $2
   21    15        INIT_FCALL                                               'calculateaccuracy'
         16        SEND_VAL                                                 -160
         17        SEND_VAL                                                 -70
         18        DO_FCALL                                      0  $3      
         19        ECHO                                                     $3
   22    20        INIT_FCALL                                               'calculateaccuracy'
         21        SEND_VAL                                                 -180
         22        SEND_VAL                                                 -70
         23        DO_FCALL                                      0  $4      
         24        ECHO                                                     $4
   23    25        INIT_FCALL                                               'calculateaccuracy'
         26        SEND_VAL                                                 -200
         27        SEND_VAL                                                 -70
         28        DO_FCALL                                      0  $5      
         29        ECHO                                                     $5
   24    30        INIT_FCALL                                               'calculateaccuracy'
         31        SEND_VAL                                                 -220
         32        SEND_VAL                                                 -70
         33        DO_FCALL                                      0  $6      
         34        ECHO                                                     $6
         35      > RETURN                                                   1

Function calculateaccuracy:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VVY1l
function name:  calculateAccuracy
number of ops:  25
compiled vars:  !0 = $txPower, !1 = $rssi, !2 = $ratio, !3 = $accuracy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        IS_EQUAL                                                 !1, 0
          3      > JMPZ                                                     ~4, ->5
    5     4    > > RETURN                                                   -1
    8     5    >   MUL                                              ~5      !1, 1
          6        DIV                                              ~6      ~5, !0
          7        ASSIGN                                                   !2, ~6
    9     8        IS_SMALLER                                               !2, 1
          9      > JMPZ                                                     ~8, ->16
   10    10    >   INIT_FCALL                                               'pow'
         11        SEND_VAR                                                 !2
         12        SEND_VAL                                                 10
         13        DO_ICALL                                         $9      
         14      > RETURN                                                   $9
         15*       JMP                                                      ->24
   13    16    >   INIT_FCALL                                               'pow'
         17        SEND_VAR                                                 !2
         18        SEND_VAL                                                 7.7095
         19        DO_ICALL                                         $10     
         20        MUL                                              ~11     $10, 0.89976
         21        ADD                                              ~12     ~11, 0.111
         22        ASSIGN                                                   !3, ~12
   14    23      > RETURN                                                   !3
   16    24*     > RETURN                                                   null

End of function calculateaccuracy

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.92 ms | 1403 KiB | 22 Q