3v4l.org

run code in 300+ PHP versions simultaneously
<?php $number = 3.0000000002; $precision = 12; $delta = pow(0.1, $precision); $rounded = round($number, $precision); if (abs($number -$rounded) < $delta) { $roundedResult = intval($number); } $intedResult = $number; if ((int) $number == $number){ $intedResult = (int) $number; } echo "Source number: ".$number.PHP_EOL; echo "Rounded result: ".$roundedResult.PHP_EOL; echo "Inted result: ".$intedResult.PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 20
filename:       /in/YK10W
function name:  (null)
number of ops:  36
compiled vars:  !0 = $number, !1 = $precision, !2 = $delta, !3 = $rounded, !4 = $roundedResult, !5 = $intedResult
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 3
    6     1        ASSIGN                                                   !1, 12
    8     2        INIT_FCALL                                               'pow'
          3        SEND_VAL                                                 0.1
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !2, $8
   11     7        INIT_FCALL                                               'round'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !3, $10
   13    12        INIT_FCALL                                               'abs'
         13        SUB                                              ~12     !0, !3
         14        SEND_VAL                                                 ~12
         15        DO_ICALL                                         $13     
         16        IS_SMALLER                                               $13, !2
         17      > JMPZ                                                     ~14, ->20
   14    18    >   CAST                                          4  ~15     !0
         19        ASSIGN                                                   !4, ~15
   17    20    >   ASSIGN                                                   !5, !0
   19    21        CAST                                          4  ~18     !0
         22        IS_EQUAL                                                 !0, ~18
         23      > JMPZ                                                     ~19, ->26
   20    24    >   CAST                                          4  ~20     !0
         25        ASSIGN                                                   !5, ~20
   24    26    >   CONCAT                                           ~22     'Source+number%3A+', !0
         27        CONCAT                                           ~23     ~22, '%0A'
         28        ECHO                                                     ~23
   25    29        CONCAT                                           ~24     'Rounded+result%3A+', !4
         30        CONCAT                                           ~25     ~24, '%0A'
         31        ECHO                                                     ~25
   26    32        CONCAT                                           ~26     'Inted+result%3A+', !5
         33        CONCAT                                           ~27     ~26, '%0A'
         34        ECHO                                                     ~27
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.35 ms | 1388 KiB | 19 Q