Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401]

(no description)

File Size: 218 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Round:: (6 methods):
  round()
  up()
  down()
  multiple()
  even()
  odd()


Class: Round  - X-Ref

round($number, $precision)   X-Ref
ROUND.

Returns the result of builtin function round after validating args.

param: mixed $number Should be numeric, or can be an array of numbers
param: mixed $precision Should be int, or can be an array of numbers
return: array|float|string Rounded number

up($number, $digits)   X-Ref
ROUNDUP.

Rounds a number up to a specified number of decimal places

param: array|float $number Number to round, or can be an array of numbers
param: array|int $digits Number of digits to which you want to round $number, or can be an array of numbers
return: array|float|string Rounded Number, or a string containing an error

down($number, $digits)   X-Ref
ROUNDDOWN.

Rounds a number down to a specified number of decimal places

param: array|float $number Number to round, or can be an array of numbers
param: array|int $digits Number of digits to which you want to round $number, or can be an array of numbers
return: array|float|string Rounded Number, or a string containing an error

multiple($number, $multiple)   X-Ref
MROUND.

Rounds a number to the nearest multiple of a specified value

param: mixed $number Expect float. Number to round, or can be an array of numbers
param: mixed $multiple Expect int. Multiple to which you want to round, or can be an array of numbers.
return: array|float|string Rounded Number, or a string containing an error

even($number)   X-Ref
EVEN.

Returns number rounded up to the nearest even integer.
You can use this function for processing items that come in twos. For example,
a packing crate accepts rows of one or two items. The crate is full when
the number of items, rounded up to the nearest two, matches the crate's
capacity.

Excel Function:
EVEN(number)

param: array|float $number Number to round, or can be an array of numbers
return: array|float|string Rounded Number, or a string containing an error

odd($number)   X-Ref
ODD.

Returns number rounded up to the nearest odd integer.

param: array|float $number Number to round, or can be an array of numbers
return: array|float|string Rounded Number, or a string containing an error