3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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); ?>
Output for 4.3.2 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
start_year and end_year could be any calendar year Usage: php /in/e9jm1 start_year end_year ex : php /in/e9jm1 2014 2030
Output for 4.3.0 - 4.3.1
Notice: Undefined variable: argv in /in/e9jm1 on line 50 Notice: Undefined variable: argv in /in/e9jm1 on line 54 Notice: Undefined variable: argv in /in/e9jm1 on line 55 start_year and end_year could be any calendar year Usage: php start_year end_year ex : php 2014 2030