3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xpnd($scientific, $precision){ # expand from scientific notation if(is_int($scientific)){ #don't convert integers return $scientific; } return sprintf("%.".$precision."F", $scientific); } function exp2int($exp) { list($mantissa, $exponent) = spliti("e", $exp); if($exponent=='') return $exp; list($int, $dec) = split("\.", $mantissa); bcscale (abs($exponent-strlen($dec))); return bcmul($mantissa, bcpow("10", $exponent)); } echo "1 - ".bcdiv(0.0000967, 2, 10)."\n"; echo "2 - ".(40075036/86164.098903691)."\n"; echo "3 - ".bcdiv(xpnd(0.0000967, 10), 2, 10)."\n"; echo exp2int("1.5");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ueGgH
function name:  (null)
number of ops:  26
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL_BY_NAME                                       'bcdiv'
          1        SEND_VAL_EX                                              9.67e-5
          2        SEND_VAL_EX                                              2
          3        SEND_VAL_EX                                              10
          4        DO_FCALL                                      0  $0      
          5        CONCAT                                           ~1      '1+-+', $0
          6        CONCAT                                           ~2      ~1, '%0A'
          7        ECHO                                                     ~2
   18     8        ECHO                                                     '2+-+465.10131841329%0A'
   19     9        INIT_FCALL_BY_NAME                                       'bcdiv'
         10        INIT_FCALL                                               'xpnd'
         11        SEND_VAL                                                 9.67e-5
         12        SEND_VAL                                                 10
         13        DO_FCALL                                      0  $3      
         14        SEND_VAR_NO_REF_EX                                       $3
         15        SEND_VAL_EX                                              2
         16        SEND_VAL_EX                                              10
         17        DO_FCALL                                      0  $4      
         18        CONCAT                                           ~5      '3+-+', $4
         19        CONCAT                                           ~6      ~5, '%0A'
         20        ECHO                                                     ~6
   20    21        INIT_FCALL                                               'exp2int'
         22        SEND_VAL                                                 '1.5'
         23        DO_FCALL                                      0  $7      
         24        ECHO                                                     $7
         25      > RETURN                                                   1

Function xpnd:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ueGgH
function name:  xpnd
number of ops:  13
compiled vars:  !0 = $scientific, !1 = $precision
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        TYPE_CHECK                                   16          !0
          3      > JMPZ                                                     ~2, ->5
    4     4    > > RETURN                                                   !0
    6     5    >   INIT_FCALL                                               'sprintf'
          6        CONCAT                                           ~3      '%25.', !1
          7        CONCAT                                           ~4      ~3, 'F'
          8        SEND_VAL                                                 ~4
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11      > RETURN                                                   $5
    7    12*     > RETURN                                                   null

End of function xpnd

Function exp2int:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ueGgH
function name:  exp2int
number of ops:  40
compiled vars:  !0 = $exp, !1 = $mantissa, !2 = $exponent, !3 = $int, !4 = $dec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL_BY_NAME                                       'spliti'
          2        SEND_VAL_EX                                              'e'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $5      
          5        FETCH_LIST_R                                     $6      $5, 0
          6        ASSIGN                                                   !1, $6
          7        FETCH_LIST_R                                     $8      $5, 1
          8        ASSIGN                                                   !2, $8
          9        FREE                                                     $5
   11    10        IS_EQUAL                                                 !2, ''
         11      > JMPZ                                                     ~10, ->13
         12    > > RETURN                                                   !0
   12    13    >   INIT_FCALL_BY_NAME                                       'split'
         14        SEND_VAL_EX                                              '%5C.'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $11     
         17        FETCH_LIST_R                                     $12     $11, 0
         18        ASSIGN                                                   !3, $12
         19        FETCH_LIST_R                                     $14     $11, 1
         20        ASSIGN                                                   !4, $14
         21        FREE                                                     $11
   13    22        INIT_FCALL_BY_NAME                                       'bcscale'
         23        INIT_FCALL                                               'abs'
         24        STRLEN                                           ~16     !4
         25        SUB                                              ~17     !2, ~16
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR_NO_REF_EX                                       $18
         29        DO_FCALL                                      0          
   14    30        INIT_FCALL_BY_NAME                                       'bcmul'
         31        SEND_VAR_EX                                              !1
         32        INIT_FCALL_BY_NAME                                       'bcpow'
         33        SEND_VAL_EX                                              '10'
         34        SEND_VAR_EX                                              !2
         35        DO_FCALL                                      0  $20     
         36        SEND_VAR_NO_REF_EX                                       $20
         37        DO_FCALL                                      0  $21     
         38      > RETURN                                                   $21
   15    39*     > RETURN                                                   null

End of function exp2int

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.93 ms | 1403 KiB | 31 Q