3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.69 ms | 1396 KiB | 19 Q