HH\Lib\Math\round

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

This function is available as Math\round() in Facebook's www repository.

Returns the given number rounded to the specified precision

Description

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