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); } /**********************************************/ $year = 2014; $limit = 2104; main($year, $limit); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hLV9f
function name:  (null)
number of ops:  7
compiled vars:  !0 = $year, !1 = $limit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   ASSIGN                                                   !0, 2014
   52     1        ASSIGN                                                   !1, 2104
   53     2        INIT_FCALL                                               'main'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0          
   56     6      > 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/hLV9f
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/hLV9f
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:
149.41 ms | 1403 KiB | 18 Q