3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** results in hhvm differ from php's **/ function main($year, $limit) { $PERIOD = 0.080905722906849315068493150684932; $PERIOD_HALF = 0.040452861453424657534246575342; //printf("PERIOD : %.33f\n", $PERIOD); //printf("PERIOD_HALF: %.33f\n", $PERIOD_HALF); $old = 0; do { $year += $PERIOD; $jde = calc($year, 0.0); if ($old != 0) { $diff = $jde - $old; if ($diff > 40) { $year2 = $year - $PERIOD_HALF; $jde2 = calc($year2, 0.0); $jde2 = calc($year2, 0.5); } } $jde = calc($year, 0.5); $old = $jde; } while ($year <= $limit); } function calc($year, $phase) { $k = floor(($year - 2000) * 12.3685); $k += $phase; $T = $k / 1236.85; $jde = 2451550.09766 + 29.530588861 * $k + (0.00015437 + (-0.000000150 + 0.00000000073 * $T) * $T) * $T * $T; //Print by changing %.12f from %.1f ~ %12.f or more //It's not the problem of printf/sprintf. But it's much more about arithmetic calculation. printf("%.10f %.1f %.1f\n", $jde, $k, $phase); } /**********************************************/ if (count($argv) != 3) { print " start_year and end_year could be any calendar year Usage: php $argv[0] start_year end_year ex : php $argv[0] 2014 2030 "; exit; } $year = $argv[1]; $limit = $argv[2]; if($year > $limit) { print " end_year($limit) must be greater than or equal to start_year($year) "; exit; } if($year < -13000 || $limit > 17000) { print " Range: -13000 ~ 17000 "; exit; } main($year, $limit); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/e9jm1
function name:  (null)
number of ops:  37
compiled vars:  !0 = $argv, !1 = $year, !2 = $limit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   COUNT                                            ~3      !0
          1        IS_NOT_EQUAL                                             ~3, 3
          2      > JMPZ                                                     ~4, ->12
   51     3    >   ROPE_INIT                                     5  ~8      '%0Astart_year+and+end_year+could+be+any+calendar+year%0A%0AUsage%3A+php+'
   54     4        FETCH_DIM_R                                      ~5      !0, 0
          5        ROPE_ADD                                      1  ~8      ~8, ~5
          6        ROPE_ADD                                      2  ~8      ~8, '+start_year+end_year%0Aex+++%3A+php+'
   55     7        FETCH_DIM_R                                      ~6      !0, 0
          8        ROPE_ADD                                      3  ~8      ~8, ~6
          9        ROPE_END                                      4  ~7      ~8, '+2014+2030%0A'
         10        ECHO                                                     ~7
   57    11      > EXIT                                                     
   60    12    >   FETCH_DIM_R                                      ~11     !0, 1
         13        ASSIGN                                                   !1, ~11
   61    14        FETCH_DIM_R                                      ~13     !0, 2
         15        ASSIGN                                                   !2, ~13
   63    16        IS_SMALLER                                               !2, !1
         17      > JMPZ                                                     ~15, ->25
   64    18    >   ROPE_INIT                                     5  ~17     '%0Aend_year%28'
   65    19        ROPE_ADD                                      1  ~17     ~17, !2
         20        ROPE_ADD                                      2  ~17     ~17, '%29+must+be+greater+than+or+equal+to+start_year%28'
         21        ROPE_ADD                                      3  ~17     ~17, !1
         22        ROPE_END                                      4  ~16     ~17, '%29%0A'
         23        ECHO                                                     ~16
   67    24      > EXIT                                                     
   70    25    >   IS_SMALLER                                       ~20     !1, -13000
         26      > JMPNZ_EX                                         ~20     ~20, ->29
         27    >   IS_SMALLER                                       ~21     17000, !2
         28        BOOL                                             ~20     ~21
         29    > > JMPZ                                                     ~20, ->32
   71    30    >   ECHO                                                     '%0ARange%3A+-13000+%7E+17000%0A'
   74    31      > EXIT                                                     
   78    32    >   INIT_FCALL                                               'main'
         33        SEND_VAR                                                 !1
         34        SEND_VAR                                                 !2
         35        DO_FCALL                                      0          
   81    36      > RETURN                                                   1

Function main:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 29
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 5
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
Branch analysis from position: 29
Branch analysis from position: 29
filename:       /in/e9jm1
function name:  main
number of ops:  38
compiled vars:  !0 = $year, !1 = $limit, !2 = $PERIOD, !3 = $PERIOD_HALF, !4 = $old, !5 = $jde, !6 = $diff, !7 = $year2, !8 = $jde2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        ASSIGN                                                   !2, 0.0809057
    9     3        ASSIGN                                                   !3, 0.0404529
   14     4        ASSIGN                                                   !4, 0
   16     5    >   ASSIGN_OP                                     1          !0, !2
   17     6        INIT_FCALL_BY_NAME                                       'calc'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAL_EX                                              0
          9        DO_FCALL                                      0  $13     
         10        ASSIGN                                                   !5, $13
   18    11        IS_NOT_EQUAL                                             !4, 0
         12      > JMPZ                                                     ~15, ->29
   19    13    >   SUB                                              ~16     !5, !4
         14        ASSIGN                                                   !6, ~16
   20    15        IS_SMALLER                                               40, !6
         16      > JMPZ                                                     ~18, ->29
   21    17    >   SUB                                              ~19     !0, !3
         18        ASSIGN                                                   !7, ~19
   22    19        INIT_FCALL_BY_NAME                                       'calc'
         20        SEND_VAR_EX                                              !7
         21        SEND_VAL_EX                                              0
         22        DO_FCALL                                      0  $21     
         23        ASSIGN                                                   !8, $21
   23    24        INIT_FCALL_BY_NAME                                       'calc'
         25        SEND_VAR_EX                                              !7
         26        SEND_VAL_EX                                              0.5
         27        DO_FCALL                                      0  $23     
         28        ASSIGN                                                   !8, $23
   27    29    >   INIT_FCALL_BY_NAME                                       'calc'
         30        SEND_VAR_EX                                              !0
         31        SEND_VAL_EX                                              0.5
         32        DO_FCALL                                      0  $25     
         33        ASSIGN                                                   !5, $25
   28    34        ASSIGN                                                   !4, !5
   30    35        IS_SMALLER_OR_EQUAL                                      !0, !1
         36      > JMPNZ                                                    ~28, ->5
   31    37    > > RETURN                                                   null

End of function main

Function calc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e9jm1
function name:  calc
number of ops:  28
compiled vars:  !0 = $year, !1 = $phase, !2 = $k, !3 = $T, !4 = $jde
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2        INIT_FCALL                                               'floor'
          3        SUB                                              ~5      !0, 2000
          4        MUL                                              ~6      ~5, 12.3685
          5        SEND_VAL                                                 ~6
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   36     8        ASSIGN_OP                                     1          !2, !1
   37     9        DIV                                              ~10     !2, 1236.85
         10        ASSIGN                                                   !3, ~10
   39    11        MUL                                              ~12     !2, 29.5306
         12        ADD                                              ~13     2.45155e+6, ~12
   40    13        MUL                                              ~14     !3, 7.3e-10
         14        ADD                                              ~15     -1.5e-7, ~14
         15        MUL                                              ~16     !3, ~15
         16        ADD                                              ~17     0.00015437, ~16
         17        MUL                                              ~18     !3, ~17
         18        MUL                                              ~19     !3, ~18
         19        ADD                                              ~20     ~13, ~19
   39    20        ASSIGN                                                   !4, ~20
   44    21        INIT_FCALL                                               'printf'
         22        SEND_VAL                                                 '%25.10f+%25.1f+%25.1f%0A'
         23        SEND_VAR                                                 !4
         24        SEND_VAR                                                 !2
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
   46    27      > RETURN                                                   null

End of function calc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.37 ms | 1407 KiB | 18 Q