3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isEqual($a, $b, $epsilon = 1e-10) { $a = floatval($a); $b = floatval($b); /*if ( $a == $b ) // handles infinites return true;*/ if ( $a * $b == 0 ) // a or b or both are zero return abs($a - $b) < ( $epsilon * $epsilon ); return (abs($a - $b) / (abs($a) + abs($b))) < $epsilon; } for ( $i = 0; $i < 10000; $i++ ) isEqual(0.000001, 0.000001);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
Branch analysis from position: 2
filename:       /in/1X5Pl
function name:  (null)
number of ops:  10
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->7
   16     2    >   INIT_FCALL                                               'isequal'
          3        SEND_VAL                                                 1.0e-6
          4        SEND_VAL                                                 1.0e-6
          5        DO_FCALL                                      0          
   15     6        PRE_INC                                                  !0
          7    >   IS_SMALLER                                               !0, 10000
          8      > JMPNZ                                                    ~4, ->2
   16     9    > > RETURN                                                   1

Function isequal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1X5Pl
function name:  isEqual
number of ops:  32
compiled vars:  !0 = $a, !1 = $b, !2 = $epsilon
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      1.0e-10
    4     3        CAST                                          5  ~3      !0
          4        ASSIGN                                                   !0, ~3
    5     5        CAST                                          5  ~5      !1
          6        ASSIGN                                                   !1, ~5
    9     7        MUL                                              ~7      !0, !1
          8        IS_EQUAL                                                 ~7, 0
          9      > JMPZ                                                     ~8, ->17
   10    10    >   INIT_FCALL                                               'abs'
         11        SUB                                              ~9      !0, !1
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        MUL                                              ~11     !2, !2
         15        IS_SMALLER                                       ~12     $10, ~11
         16      > RETURN                                                   ~12
   12    17    >   INIT_FCALL                                               'abs'
         18        SUB                                              ~13     !0, !1
         19        SEND_VAL                                                 ~13
         20        DO_ICALL                                         $14     
         21        INIT_FCALL                                               'abs'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $15     
         24        INIT_FCALL                                               'abs'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $16     
         27        ADD                                              ~17     $15, $16
         28        DIV                                              ~18     $14, ~17
         29        IS_SMALLER                                       ~19     ~18, !2
         30      > RETURN                                                   ~19
   13    31*     > RETURN                                                   null

End of function isequal

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.93 ms | 1402 KiB | 16 Q