3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertFloat($float) { $float = (string)$float; $expPos = strpos($float, 'E'); var_dump($float); 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)); if ($exp === 0) { return '1'; } $dotPos = strpos($numberWithoutPrecision, '.'); if ($dotPos === false) { $beforeDot = $numberWithoutPrecision; } else { $beforeDot = substr($numberWithoutPrecision, 0, $dotPos); $afterDot = substr($numberWithoutPrecision, $dotPos + 1, strlen($numberWithoutPrecision)); } if ($exp < 0) { $len = strlen($afterDot); if ($len <= $exp) { return $beforeDot.$afterDot; } } else { $len = strlen($afterDot); return $beforeDot.($afterDot !== '0' ? $afterDot : '').str_repeat('0', $exp - $len).'i'; } var_dump($beforeDot, $afterDot); } convertFloat('1.11111111111111111111111111111111111111111111111111111111111e+60');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EZn3V
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'convertfloat'
          1        SEND_VAL                                                 '1.11111111111111111111111111111111111111111111111111111111111e%2B60'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function convertfloat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 34
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 66
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 72
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 66
Branch analysis from position: 59
Branch analysis from position: 66
filename:       /in/EZn3V
function name:  convertFloat
number of ops:  87
compiled vars:  !0 = $float, !1 = $expPos, !2 = $beforeDot, !3 = $afterDot, !4 = $numberWithoutPrecision, !5 = $exp, !6 = $dotPos, !7 = $len
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        CAST                                          6  ~8      !0
          2        ASSIGN                                                   !0, ~8
    5     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'E'
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !1, $10
    6     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
    7    11        TYPE_CHECK                                    4          !1
         12      > JMPZ                                                     ~13, ->14
    8    13    > > RETURN                                                   !0
   11    14    >   ASSIGN                                                   !2, '0'
   12    15        ASSIGN                                                   !3, '0'
   13    16        INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 0
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $16     
         21        ASSIGN                                                   !4, $16
   14    22        INIT_FCALL                                               'substr'
         23        SEND_VAR                                                 !0
         24        ADD                                              ~18     !1, 1
         25        SEND_VAL                                                 ~18
         26        STRLEN                                           ~19     !0
         27        SEND_VAL                                                 ~19
         28        DO_ICALL                                         $20     
         29        CAST                                          4  ~21     $20
         30        ASSIGN                                                   !5, ~21
   16    31        IS_IDENTICAL                                             !5, 0
         32      > JMPZ                                                     ~23, ->34
   17    33    > > RETURN                                                   '1'
   20    34    >   INIT_FCALL                                               'strpos'
         35        SEND_VAR                                                 !4
         36        SEND_VAL                                                 '.'
         37        DO_ICALL                                         $24     
         38        ASSIGN                                                   !6, $24
   22    39        TYPE_CHECK                                    4          !6
         40      > JMPZ                                                     ~26, ->43
   23    41    >   ASSIGN                                                   !2, !4
         42      > JMP                                                      ->57
   25    43    >   INIT_FCALL                                               'substr'
         44        SEND_VAR                                                 !4
         45        SEND_VAL                                                 0
         46        SEND_VAR                                                 !6
         47        DO_ICALL                                         $28     
         48        ASSIGN                                                   !2, $28
   26    49        INIT_FCALL                                               'substr'
         50        SEND_VAR                                                 !4
         51        ADD                                              ~30     !6, 1
         52        SEND_VAL                                                 ~30
         53        STRLEN                                           ~31     !4
         54        SEND_VAL                                                 ~31
         55        DO_ICALL                                         $32     
         56        ASSIGN                                                   !3, $32
   29    57    >   IS_SMALLER                                               !5, 0
         58      > JMPZ                                                     ~34, ->66
   30    59    >   STRLEN                                           ~35     !3
         60        ASSIGN                                                   !7, ~35
   32    61        IS_SMALLER_OR_EQUAL                                      !7, !5
         62      > JMPZ                                                     ~37, ->65
   33    63    >   CONCAT                                           ~38     !2, !3
         64      > RETURN                                                   ~38
         65    > > JMP                                                      ->82
   36    66    >   STRLEN                                           ~39     !3
         67        ASSIGN                                                   !7, ~39
   38    68        IS_NOT_IDENTICAL                                         !3, '0'
         69      > JMPZ                                                     ~41, ->72
         70    >   QM_ASSIGN                                        ~42     !3
         71      > JMP                                                      ->73
         72    >   QM_ASSIGN                                        ~42     ''
         73    >   CONCAT                                           ~43     !2, ~42
         74        INIT_FCALL                                               'str_repeat'
         75        SEND_VAL                                                 '0'
         76        SUB                                              ~44     !5, !7
         77        SEND_VAL                                                 ~44
         78        DO_ICALL                                         $45     
         79        CONCAT                                           ~46     ~43, $45
         80        CONCAT                                           ~47     ~46, 'i'
         81      > RETURN                                                   ~47
   41    82    >   INIT_FCALL                                               'var_dump'
         83        SEND_VAR                                                 !2
         84        SEND_VAR                                                 !3
         85        DO_ICALL                                                 
   42    86      > RETURN                                                   null

End of function convertfloat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.53 ms | 1411 KiB | 22 Q