3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mround($number, $precision=0) { $precision = ($precision == 0 ? 1 : $precision); $pow = pow(10, $precision); $ceil = ceil($number * $pow)/$pow; $floor = floor($number * $pow)/$pow; $pow = pow(10, $precision+1); $diffCeil = $pow*($ceil-$number); $diffFloor = $pow*($number-$floor)+($number < 0 ? -1 : 1); if($diffCeil >= $diffFloor) return $floor; else return $ceil; } echo mround(4.725, 2); // Yes 4.73
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mWMo8
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'mround'
          1        SEND_VAL                                                 4.725
          2        SEND_VAL                                                 2
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function mround:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
Branch analysis from position: 47
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
Branch analysis from position: 40
filename:       /in/mWMo8
function name:  mround
number of ops:  49
compiled vars:  !0 = $number, !1 = $precision, !2 = $pow, !3 = $ceil, !4 = $floor, !5 = $diffCeil, !6 = $diffFloor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
    4     2        IS_EQUAL                                                 !1, 0
          3      > JMPZ                                                     ~7, ->6
          4    >   QM_ASSIGN                                        ~8      1
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~8      !1
          7    >   ASSIGN                                                   !1, ~8
    5     8        INIT_FCALL                                               'pow'
          9        SEND_VAL                                                 10
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !2, $10
    7    13        INIT_FCALL                                               'ceil'
         14        MUL                                              ~12     !0, !2
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        DIV                                              ~14     $13, !2
         18        ASSIGN                                                   !3, ~14
    8    19        INIT_FCALL                                               'floor'
         20        MUL                                              ~16     !0, !2
         21        SEND_VAL                                                 ~16
         22        DO_ICALL                                         $17     
         23        DIV                                              ~18     $17, !2
         24        ASSIGN                                                   !4, ~18
   10    25        INIT_FCALL                                               'pow'
         26        SEND_VAL                                                 10
         27        ADD                                              ~20     !1, 1
         28        SEND_VAL                                                 ~20
         29        DO_ICALL                                         $21     
         30        ASSIGN                                                   !2, $21
   12    31        SUB                                              ~23     !3, !0
         32        MUL                                              ~24     !2, ~23
         33        ASSIGN                                                   !5, ~24
   13    34        SUB                                              ~26     !0, !4
         35        MUL                                              ~27     !2, ~26
         36        IS_SMALLER                                               !0, 0
         37      > JMPZ                                                     ~28, ->40
         38    >   QM_ASSIGN                                        ~29     -1
         39      > JMP                                                      ->41
         40    >   QM_ASSIGN                                        ~29     1
         41    >   ADD                                              ~30     ~27, ~29
         42        ASSIGN                                                   !6, ~30
   15    43        IS_SMALLER_OR_EQUAL                                      !6, !5
         44      > JMPZ                                                     ~32, ->47
         45    > > RETURN                                                   !4
         46*       JMP                                                      ->48
   16    47    > > RETURN                                                   !3
   17    48*     > RETURN                                                   null

End of function mround

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.84 ms | 1403 KiB | 20 Q