3v4l.org

run code in 300+ PHP versions simultaneously
<?php $precision = 15; $delta = pow(0.1, $precision); $number = 3 + ($delta * 2); $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 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 23
filename:       /in/osQqR
function name:  (null)
number of ops:  39
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, 15
    8     1        INIT_FCALL                                               'pow'
          2        SEND_VAL                                                 0.1
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   11     6        MUL                                              ~9      !1, 2
          7        ADD                                              ~10     3, ~9
          8        ASSIGN                                                   !2, ~10
   14     9        INIT_FCALL                                               'round'
         10        SEND_VAR                                                 !2
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $12     
         13        ASSIGN                                                   !3, $12
   17    14        ASSIGN                                                   !4, !2
   22    15        INIT_FCALL                                               'abs'
         16        SUB                                              ~15     !2, !3
         17        SEND_VAL                                                 ~15
         18        DO_ICALL                                         $16     
         19        IS_SMALLER                                               $16, !1
         20      > JMPZ                                                     ~17, ->23
   23    21    >   CAST                                          4  ~18     !2
         22        ASSIGN                                                   !4, ~18
   26    23    >   ASSIGN                                                   !5, !2
   28    24        CAST                                          4  ~21     !2
         25        IS_EQUAL                                                 !2, ~21
         26      > JMPZ                                                     ~22, ->29
   29    27    >   CAST                                          4  ~23     !2
         28        ASSIGN                                                   !5, ~23
   35    29    >   CONCAT                                           ~25     'Source+number%3A+', !2
         30        CONCAT                                           ~26     ~25, '%0A'
         31        ECHO                                                     ~26
   36    32        CONCAT                                           ~27     'Rounded+result%3A+', !4
         33        CONCAT                                           ~28     ~27, '%0A'
         34        ECHO                                                     ~28
   37    35        CONCAT                                           ~29     'Inted+result%3A+', !5
         36        CONCAT                                           ~30     ~29, '%0A'
         37        ECHO                                                     ~30
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.49 ms | 1396 KiB | 19 Q