3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* convert 64-bit numeric string to decimal */ function showDecimal( $bin, $base ) { if ($bin[0] == 'F' && $bin[1] == 'F'){ $bin = substr($bin,1); // trim string so may } $num = intval( $bin, $base ); // convert to binary number $num &= 0xffff; // using only rightmost 16 bits if ( 0x8000 & $num ) { // true if $num is negative ... $num =( $num - (2 ** 16) ); $num2 = -((2 ** 16) - 0xfffd); var_dump($num2); } return $num; } $c = "FFFFFFFFFFFFFFFD"; // TC in hexadecimal for: echo showDecimal($c,16),"\n"; // -3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/stSem
function name:  (null)
number of ops:  8
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, 'FFFFFFFFFFFFFFFD'
   20     1        INIT_FCALL                                               'showdecimal'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 16
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6        ECHO                                                     '%0A'
          7      > RETURN                                                   1

Function showdecimal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 14
Branch analysis from position: 8
filename:       /in/stSem
function name:  showDecimal
number of ops:  30
compiled vars:  !0 = $bin, !1 = $base, !2 = $num, !3 = $num2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        FETCH_DIM_R                                      ~4      !0, 0
          3        IS_EQUAL                                         ~5      ~4, 'F'
          4      > JMPZ_EX                                          ~5      ~5, ->8
          5    >   FETCH_DIM_R                                      ~6      !0, 1
          6        IS_EQUAL                                         ~7      ~6, 'F'
          7        BOOL                                             ~5      ~7
          8    > > JMPZ                                                     ~5, ->14
    6     9    >   INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 1
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !0, $8
    8    14    >   INIT_FCALL                                               'intval'
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !2, $10
   10    19        ASSIGN_OP                                    10          !2, 65535
   11    20        BW_AND                                           ~13     !2, 32768
         21      > JMPZ                                                     ~13, ->28
   12    22    >   SUB                                              ~14     !2, 65536
         23        ASSIGN                                                   !2, ~14
   13    24        ASSIGN                                                   !3, -3
   14    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                                 
   17    28    > > RETURN                                                   !2
   18    29*     > RETURN                                                   null

End of function showdecimal

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.91 ms | 1403 KiB | 20 Q