Skip to content

Commit

Permalink
added an assert for roundingMode in PHP fix #2171
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed May 31, 2018
1 parent c323a36 commit c66a4b3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions php/Exchange.php
Expand Up @@ -1806,6 +1806,7 @@ public static function decimalToPrecision ($x, $roundingMode = ROUND, $numPrecis
}

public static function decimal_to_precision ($x, $roundingMode = ROUND, $numPrecisionDigits = null, $countingMode = DECIMAL_PLACES, $paddingMode = NO_PADDING) {

if ($numPrecisionDigits < 0) {
throw new BaseError ('Negative precision is not yet supported');
}
Expand All @@ -1818,6 +1819,8 @@ public static function decimal_to_precision ($x, $roundingMode = ROUND, $numPrec
throw new BaseError ('Invalid number');
}

assert ($roundingMode === ROUND || $roundingMode === TRUNCATE);

$result = '';
if ($roundingMode === ROUND) {
if ($countingMode === DECIMAL_PLACES) {
Expand Down

0 comments on commit c66a4b3

Please sign in to comment.