3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $date = "2016/6"; $rate = "2.90"; $summer = 7; $winter = 1; $bonus = 100000; $bcount = 30; $rate = $rate / 100; $hoge = get1_3($date, $rate, $summer, $winter, $bonus, $bcount); echo $hoge; function get1_3($date, $rate, $summer, $winter, $bonus, $bcount) { // 【1-3-1-1-1】AQ11 「初回利率」(少数12桁) // = +ROUNDDOWN(★手数料率(年利) * AP10 / 12, 12) $b_first_rate = getFirstRate($date, $rate, $summer, $winter); ##OK #echo $b_first_rate . "\r\n"; #exit; // 【1-3-1-1-2】AP4 「月利」(少数12桁) // = ROUND(★手数料率(年利) / 12, 12) $b_month_rate = round($rate / 12, 12); ##OK #echo $b_month_rate . "\r\n"; #exit; // 【1-3-1-1-4】AV18  // = +IF(ボーナス月1 = 8, VLOOKUP(★開始月, "1~12", 2, 0), VLOOKUP(★開始月, "5 or 7", 3, 0)) $t_date = explode("/", $date); $month = $t_date[1]; if(8 == $summer) { $a_bonusMonthArray = array( 1 => 7, 2 => 7, 3 => 7, 4 => 7, 5 => 7, 6 => 7, 7 => 7, 8 => 5, 9 => 5, 10 => 5, 11 => 5, 12 => 5); } else { $a_bonusMonthArray = array( 1 => 5, 2 => 7, 3 => 7, 4 => 7, 5 => 7, 6 => 7, 7 => 7, 8 => 7, 9 => 5, 10 => 5, 11 => 5, 12 => 5); } $keyNumber1 = $a_bonusMonthArray[$month]; ##OK #echo $keyNumber1 . "\r\n"; // ??? // 【1-3-1-1-3】AW18  // = +IF(【1-3-1-1-4】 = 5, 7, 5) if(5 == $keyNumber1) { $keyNumber2 = 7; } else { $keyNumber2 = 5; } #OK #echo $keyNumber2 . "\r\n"; #exit; //【1-3-1-1】AP22 「賦金率分子」 // = (1 + 【1-3-1-1-1】) * (1 + 【1-3-1-1-2】 * 【1-3-1-1-3】)^((【1-0-1】-1) / 2) * (1 + 【1-3-1-1-2】 * 【1-3-1-1-4】)^((【1-0-1】- 1) / 2) * ((1 + 【1-3-1-1-2】 * 【1-3-1-1-3】) * (1 + 【1-3-1-1-2】 * 【1-3-1-1-4】) - 1) $b_inst_numerator = (1 + $b_first_rate) * pow((1 + $b_month_rate * $keyNumber2),(($bcount - 1) / 2)) * pow((1 + $b_month_rate * $keyNumber1),(($bcount- 1) / 2)) * ((1 + $b_month_rate * $keyNumber2) * (1 + $b_month_rate * $keyNumber1) - 1); //【1-3-1-2】AP23 賦金率分母」 // = (1 + (1 + 【1-3-1-1-2】*【1-3-1-1-4】)) * ((1 +【1-3-1-1-2】*【1-3-1-1-3】)^((【1-0-1】-1)/2) * (1 +【1-3-1-1-2】*【1-3-1-1-4】)^((【1-0-1】- 1) / 2) - 1) + (1 +【1-3-1-1-2】*【1-3-1-1-3】)^((【1-0-1】- 1) / 2) * (1 +【1-3-1-1-2】*【1-3-1-1-4】) ^ ((【1-0-1】- 1) / 2) * ((1 +【1-3-1-1-2】*【1-3-1-1-3】) * (1 + 【1-3-1-1-2】*【1-3-1-1-4】) - 1) $b_inst_denominator = (1 + (1 + $b_month_rate * $keyNumber1)) * ( pow((1 + $b_month_rate * $keyNumber2),(($bcount - 1) / 2)) * pow((1 + $b_month_rate * $keyNumber1),(($bcount - 1) / 2)) - 1 ) + pow((1 + $b_month_rate * $keyNumber2),(($bcount - 1) / 2)) * pow((1 + $b_month_rate * $keyNumber1),(($bcount - 1) / 2)) * ((1 + $b_month_rate * $keyNumber2) * (1 + $b_month_rate * $keyNumber1) - 1); ##OK #echo $b_inst_numerator . "\r\n"; #echo (1 + (1 + $b_month_rate * $keyNumber1)) ; #exit; echo $b_inst_denominator . "\r\n"; exit; //【1-3-1】BE24 // = +ROUNDDOWN(【1-3-1-1】 / 【1-3-1-2】, 12) $b_result = round($b_inst_numerator / $b_inst_denominator, 12, PHP_ROUND_HALF_DOWN); //【1-3】BE25 ③ボーナス不均・奇数 // = +ROUNDUP(★ボーナス加算希望額 / 【1-3-1】,0) return round($bonus / $b_result, 0, PHP_ROUND_HALF_UP); } function getFirstRate($date, $rate, $summer, $winter) { //【1-2-1-2】AP11 「初回利率」(少数5桁) // = +ROUNDDOWN(★手数料率(年利) * 【1-2-1-2-1】 / 12, 5) // 【1-2-1-2-1】AP10 「初回期間」※支払開始後、最初のボーナス月までのヶ月 $t_date = explode("/", $date); $month = $t_date[1]; $monthCount = 0; while($monthCount < 12) { $monthCount++; $check = $month + $monthCount; if($check > 12) { $check = $check - 12; } if($check == $summer || $check == $winter) { $monthCount++; break; } } return round($rate * $monthCount / 12, 12, PHP_ROUND_HALF_DOWN); }
based on scaH2
Output for 5.6.0 - 7.3.0alpha1
1.089109317107