3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertOld($input) { $oldMin = 0; $oldMax = 1; $newMin = 127; $newMax = 0; return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin); } function convertNew($input) { $range_input = range(1, 0, 1/127); $range_output = range(0, 127); foreach ($range_input as $key => $value) { if ($value <= $input) { return $range_output[$key]; } } return 127; } $warnings = []; foreach (range(0,1,1/1000) as $input) { if (convertOld($input) != convertNew($input)) $warnings[] = $input; } var_dump($warnings);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 19
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/5RbsD
function name:  (null)
number of ops:  24
compiled vars:  !0 = $warnings, !1 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, <array>
   28     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 0.001
          5        DO_ICALL                                         $3      
          6      > FE_RESET_R                                       $4      $3, ->19
          7    > > FE_FETCH_R                                               $4, !1, ->19
   29     8    >   INIT_FCALL                                               'convertold'
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $5      
         11        INIT_FCALL                                               'convertnew'
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0  $6      
         14        IS_NOT_EQUAL                                             $5, $6
         15      > JMPZ                                                     ~7, ->18
         16    >   ASSIGN_DIM                                               !0
         17        OP_DATA                                                  !1
   28    18    > > JMP                                                      ->7
         19    >   FE_FREE                                                  $4
   31    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function convertold:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5RbsD
function name:  convertOld
number of ops:  16
compiled vars:  !0 = $input, !1 = $oldMin, !2 = $oldMax, !3 = $newMin, !4 = $newMax
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, 0
    6     2        ASSIGN                                                   !2, 1
    7     3        ASSIGN                                                   !3, 127
    8     4        ASSIGN                                                   !4, 0
   10     5        INIT_FCALL                                               'ceil'
          6        SUB                                              ~9      !0, !1
          7        SUB                                              ~10     !4, !3
          8        MUL                                              ~11     ~9, ~10
          9        SUB                                              ~12     !2, !1
         10        DIV                                              ~13     ~11, ~12
         11        ADD                                              ~14     ~13, !3
         12        SEND_VAL                                                 ~14
         13        DO_ICALL                                         $15     
         14      > RETURN                                                   $15
   11    15*     > RETURN                                                   null

End of function convertold

Function convertnew:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/5RbsD
function name:  convertNew
number of ops:  24
compiled vars:  !0 = $input, !1 = $range_input, !2 = $range_output, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 0.00787402
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !1, $5
   16     7        INIT_FCALL                                               'range'
          8        SEND_VAL                                                 0
          9        SEND_VAL                                                 127
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !2, $7
   18    12      > FE_RESET_R                                       $9      !1, ->21
         13    > > FE_FETCH_R                                       ~10     $9, !3, ->21
         14    >   ASSIGN                                                   !4, ~10
   19    15        IS_SMALLER_OR_EQUAL                                      !3, !0
         16      > JMPZ                                                     ~12, ->20
   20    17    >   FETCH_DIM_R                                      ~13     !2, !4
         18        FE_FREE                                                  $9
         19      > RETURN                                                   ~13
   18    20    > > JMP                                                      ->13
         21    >   FE_FREE                                                  $9
   24    22      > RETURN                                                   127
   25    23*     > RETURN                                                   null

End of function convertnew

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.69 ms | 1403 KiB | 21 Q