diff --git a/reference/bc/bcmath/number/round.xml b/reference/bc/bcmath/number/round.xml index 9aed0bb0d3..ae9aff1073 100644 --- a/reference/bc/bcmath/number/round.xml +++ b/reference/bc/bcmath/number/round.xml @@ -1,6 +1,6 @@ - + @@ -26,11 +26,11 @@ - + mode - 指定する丸めモード。 + 指定する丸めモード。詳しくは RoundingMode を参照してください。 diff --git a/reference/bc/functions/bcround.xml b/reference/bc/functions/bcround.xml index d9b90f87be..908702da04 100644 --- a/reference/bc/functions/bcround.xml +++ b/reference/bc/functions/bcround.xml @@ -1,6 +1,6 @@ - + @@ -27,14 +27,7 @@ - - mode - - - 指定する丸めモード。 - - - + diff --git a/reference/math/functions/round.xml b/reference/math/functions/round.xml index 635b99b11f..475f017f4e 100644 --- a/reference/math/functions/round.xml +++ b/reference/math/functions/round.xml @@ -1,6 +1,6 @@ - + @@ -13,7 +13,7 @@ floatround intfloatnum intprecision0 - intmodePHP_ROUND_HALF_UP + intRoundingModemodeRoundingMode::HalfAwayFromZero num を、指定した @@ -76,7 +76,7 @@ mode - 次の定数のいずれかを使って、丸めのモードを指定します。 + RoundingMode もしくは次の定数のいずれかを使って、丸めのモードを指定します。 @@ -121,6 +121,7 @@ + ただし、新規に追加されたいくつかのモードは RoundingMode にのみ存在します。 @@ -134,6 +135,14 @@ + + &reftitle.errors; + + この関数は、無効な mode が指定された場合に ValueError をスローします。 + PHP 8.4.0 より前では、、エラーにはならずに PHP_ROUND_HALF_UP を使用していました。 + + + &reftitle.changelog; @@ -145,6 +154,18 @@ + + 8.4.0 + + 新しい4つのモードが追加されました。 + + + + 8.4.0 + + 無効な mode が指定された場合に ValueError をスローするようになりました。 + + 8.0.0 @@ -314,6 +335,61 @@ float(-1.5) ]]> + + <enumname>RoundingMode</enumname> を使用した例 + + %+.17g\n", $mode->name, $number, round($number, 0, $mode)); + } + echo "\n"; +} +?> +]]> + + &example.outputs; + + +9 +HalfAwayFromZero : +9.5 -> +10 +HalfAwayFromZero : -3.5 -> -4 + +HalfTowardsZero : +8.5 -> +8 +HalfTowardsZero : +9.5 -> +9 +HalfTowardsZero : -3.5 -> -3 + +HalfEven : +8.5 -> +8 +HalfEven : +9.5 -> +10 +HalfEven : -3.5 -> -4 + +HalfOdd : +8.5 -> +9 +HalfOdd : +9.5 -> +9 +HalfOdd : -3.5 -> -3 + +TowardsZero : +8.5 -> +8 +TowardsZero : +9.5 -> +9 +TowardsZero : -3.5 -> -3 + +AwayFromZero : +8.5 -> +9 +AwayFromZero : +9.5 -> +10 +AwayFromZero : -3.5 -> -4 + +NegativeInfinity : +8.5 -> +8 +NegativeInfinity : +9.5 -> +9 +NegativeInfinity : -3.5 -> -4 + +PositiveInfinity : +8.5 -> +9 +PositiveInfinity : +9.5 -> +10 +PositiveInfinity : -3.5 -> -3 +]]> + +