Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 1.06 KB

round.md

File metadata and controls

63 lines (41 loc) · 1.06 KB

round

Round every element to the nearest whole number or decimal place.

API

Numeric.math.round(value, decimals = 0)

Applies rounding across nested numeric inputs.

  • Parameters:
    • value: Scalar, vector, or matrix input values
    • decimals: Number of decimal places to keep
  • Returns: Rounded values matching the input nesting shape
  • NumPy: Covers np.round, np.around, np.rint, np.fix, ndarray.round through a single Numerix method.

Examples

Round a scalar

import Numeric from '@neabyte/numerix'

const value = Numeric.math.round(1.6)

console.log(value)
// 2

Keep two decimal places

import Numeric from '@neabyte/numerix'

const value = Numeric.math.round(1.2345, 2)

console.log(value)
// 1.23

Round a vector

import Numeric from '@neabyte/numerix'

const values = Numeric.math.round([1.4, 1.6])

console.log(values)
// [1,2]

Round a matrix

import Numeric from '@neabyte/numerix'

const values = Numeric.math.round([[1.4, 1.6], [2.5, 2.4]])

console.log(values)
// [[1,2],[2,2]]