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; } foreach (range(0,1,1/1000) as $input) { echo (convertOld($input) != convertNew($input)) ? "WARNING $input mismatch\n" : ""; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 23
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/EUQlk
function name:  (null)
number of ops:  25
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 0.001
          4        DO_ICALL                                         $1      
          5      > FE_RESET_R                                       $2      $1, ->23
          6    > > FE_FETCH_R                                               $2, !0, ->23
   28     7    >   INIT_FCALL                                               'convertold'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $3      
         10        INIT_FCALL                                               'convertnew'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0  $4      
         13        IS_NOT_EQUAL                                             $3, $4
         14      > JMPZ                                                     ~5, ->20
         15    >   ROPE_INIT                                     3  ~7      'WARNING+'
         16        ROPE_ADD                                      1  ~7      ~7, !0
         17        ROPE_END                                      2  ~6      ~7, '+mismatch%0A'
         18        QM_ASSIGN                                        ~9      ~6
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~9      ''
         21    >   ECHO                                                     ~9
   27    22      > JMP                                                      ->6
         23    >   FE_FREE                                                  $2
   29    24      > RETURN                                                   1

Function convertold:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EUQlk
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/EUQlk
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:
160.62 ms | 1403 KiB | 19 Q