3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertFloat($float) { $float = (string)$float; $expPos = strpos($float, 'e'); var_dump($float, $expPos); 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/7Ftts
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 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 67
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 66
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 83
Branch analysis from position: 83
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 73
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 67
Branch analysis from position: 60
Branch analysis from position: 67
filename:       /in/7Ftts
function name:  convertFloat
number of ops:  88
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        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
    7    12        TYPE_CHECK                                    4          !1
         13      > JMPZ                                                     ~13, ->15
    8    14    > > RETURN                                                   !0
   11    15    >   ASSIGN                                                   !2, '0'
   12    16        ASSIGN                                                   !3, '0'
   13    17        INIT_FCALL                                               'substr'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 0
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $16     
         22        ASSIGN                                                   !4, $16
   14    23        INIT_FCALL                                               'substr'
         24        SEND_VAR                                                 !0
         25        ADD                                              ~18     !1, 1
         26        SEND_VAL                                                 ~18
         27        STRLEN                                           ~19     !0
         28        SEND_VAL                                                 ~19
         29        DO_ICALL                                         $20     
         30        CAST                                          4  ~21     $20
         31        ASSIGN                                                   !5, ~21
   16    32        IS_IDENTICAL                                             !5, 0
         33      > JMPZ                                                     ~23, ->35
   17    34    > > RETURN                                                   '1'
   20    35    >   INIT_FCALL                                               'strpos'
         36        SEND_VAR                                                 !4
         37        SEND_VAL                                                 '.'
         38        DO_ICALL                                         $24     
         39        ASSIGN                                                   !6, $24
   22    40        TYPE_CHECK                                    4          !6
         41      > JMPZ                                                     ~26, ->44
   23    42    >   ASSIGN                                                   !2, !4
         43      > JMP                                                      ->58
   25    44    >   INIT_FCALL                                               'substr'
         45        SEND_VAR                                                 !4
         46        SEND_VAL                                                 0
         47        SEND_VAR                                                 !6
         48        DO_ICALL                                         $28     
         49        ASSIGN                                                   !2, $28
   26    50        INIT_FCALL                                               'substr'
         51        SEND_VAR                                                 !4
         52        ADD                                              ~30     !6, 1
         53        SEND_VAL                                                 ~30
         54        STRLEN                                           ~31     !4
         55        SEND_VAL                                                 ~31
         56        DO_ICALL                                         $32     
         57        ASSIGN                                                   !3, $32
   29    58    >   IS_SMALLER                                               !5, 0
         59      > JMPZ                                                     ~34, ->67
   30    60    >   STRLEN                                           ~35     !3
         61        ASSIGN                                                   !7, ~35
   32    62        IS_SMALLER_OR_EQUAL                                      !7, !5
         63      > JMPZ                                                     ~37, ->66
   33    64    >   CONCAT                                           ~38     !2, !3
         65      > RETURN                                                   ~38
         66    > > JMP                                                      ->83
   36    67    >   STRLEN                                           ~39     !3
         68        ASSIGN                                                   !7, ~39
   38    69        IS_NOT_IDENTICAL                                         !3, '0'
         70      > JMPZ                                                     ~41, ->73
         71    >   QM_ASSIGN                                        ~42     !3
         72      > JMP                                                      ->74
         73    >   QM_ASSIGN                                        ~42     ''
         74    >   CONCAT                                           ~43     !2, ~42
         75        INIT_FCALL                                               'str_repeat'
         76        SEND_VAL                                                 '0'
         77        SUB                                              ~44     !5, !7
         78        SEND_VAL                                                 ~44
         79        DO_ICALL                                         $45     
         80        CONCAT                                           ~46     ~43, $45
         81        CONCAT                                           ~47     ~46, 'i'
         82      > RETURN                                                   ~47
   41    83    >   INIT_FCALL                                               'var_dump'
         84        SEND_VAR                                                 !2
         85        SEND_VAR                                                 !3
         86        DO_ICALL                                                 
   42    87      > RETURN                                                   null

End of function convertfloat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.38 ms | 1407 KiB | 22 Q