3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
231.98 ms | 1400 KiB | 21 Q