3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertFloat($float) { $float = (string)$float; $expPos = strpos($float, 'E-'); if ($expPos === false) { return $float; } $beforeDot = 0; // Well, fuck you my English. $afterDot = 0; // ^^ $numberWithoutPrecision = substr($float, 0, $expPos); $exp = (int)substr($float, $expPos + 1, strlen($float)); $dotPos = strpos($numberWithoutPrecision, '.'); if ($dotPos === false) { $beforeDot = $numberWithoutPrecision; } else { $beforeDot = substr($numberWithoutPrecision, 0, $dotPos); $afterDot = substr($numberWithoutPrecision, $dotPos + 1, strlen($numberWithoutPrecision)); } var_dump($beforeDot, $afterDot); } convertFloat(1.004e-300);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odZPt
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'convertfloat'
          1        SEND_VAL                                                 1.004e-300
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function convertfloat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odZPt
function name:  convertFloat
number of ops:  56
compiled vars:  !0 = $float, !1 = $expPos, !2 = $beforeDot, !3 = $afterDot, !4 = $numberWithoutPrecision, !5 = $exp, !6 = $dotPos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        CAST                                          6  ~7      !0
          2        ASSIGN                                                   !0, ~7
    5     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'E-'
          6        DO_ICALL                                         $9      
          7        ASSIGN                                                   !1, $9
    7     8        TYPE_CHECK                                    4          !1
          9      > JMPZ                                                     ~11, ->11
    8    10    > > RETURN                                                   !0
   11    11    >   ASSIGN                                                   !2, 0
   12    12        ASSIGN                                                   !3, 0
   13    13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 0
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $14     
         18        ASSIGN                                                   !4, $14
   14    19        INIT_FCALL                                               'substr'
         20        SEND_VAR                                                 !0
         21        ADD                                              ~16     !1, 1
         22        SEND_VAL                                                 ~16
         23        STRLEN                                           ~17     !0
         24        SEND_VAL                                                 ~17
         25        DO_ICALL                                         $18     
         26        CAST                                          4  ~19     $18
         27        ASSIGN                                                   !5, ~19
   16    28        INIT_FCALL                                               'strpos'
         29        SEND_VAR                                                 !4
         30        SEND_VAL                                                 '.'
         31        DO_ICALL                                         $21     
         32        ASSIGN                                                   !6, $21
   18    33        TYPE_CHECK                                    4          !6
         34      > JMPZ                                                     ~23, ->37
   19    35    >   ASSIGN                                                   !2, !4
         36      > JMP                                                      ->51
   21    37    >   INIT_FCALL                                               'substr'
         38        SEND_VAR                                                 !4
         39        SEND_VAL                                                 0
         40        SEND_VAR                                                 !6
         41        DO_ICALL                                         $25     
         42        ASSIGN                                                   !2, $25
   22    43        INIT_FCALL                                               'substr'
         44        SEND_VAR                                                 !4
         45        ADD                                              ~27     !6, 1
         46        SEND_VAL                                                 ~27
         47        STRLEN                                           ~28     !4
         48        SEND_VAL                                                 ~28
         49        DO_ICALL                                         $29     
         50        ASSIGN                                                   !3, $29
   25    51    >   INIT_FCALL                                               'var_dump'
         52        SEND_VAR                                                 !2
         53        SEND_VAR                                                 !3
         54        DO_ICALL                                                 
   26    55      > RETURN                                                   null

End of function convertfloat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.15 ms | 1403 KiB | 20 Q