You are here

function currency_round in Currency 7.2

Divides one number by another.

Parameters

int|float|string $number: The number to round.

int|float|string $rounding_step: The step to round by. Example: when the step is 0.25, values will be rounded to the nearest quarter.

Return value

int|float|string

1 call to currency_round()
Currency::roundAmount in currency/includes/Currency.inc
Rounds an amount.

File

currency/currency.module, line 1082
Provides currency information and allows users to add custom currencies.

Code

function currency_round($number, $rounding_step) {
  if (extension_loaded('bcmath')) {
    return bcmul(round(bcdiv($number, $rounding_step, CURRENCY_BCMATH_SCALE)), $rounding_step, CURRENCY_BCMATH_SCALE);
  }
  else {
    return round($number / $rounding_step) * $rounding_step;
  }
}