HH\Lib\Math\round

This API is part of the Hack Standard Library, not HHVM itself.

Returns the given number rounded to the specified precision

namespace HH\Lib\Math;

function round(
  num $val,
  int $precision = 0,
): float;

A positive precision rounds to the nearest decimal place whereas a negative precision rounds to the nearest power of ten. For example, a precision of 1 rounds to the nearest tenth whereas a precision of -1 rounds to the nearest ten.

Parameters

  • num $val
  • int $precision = 0