Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 948 Bytes

trunc.md

File metadata and controls

62 lines (40 loc) · 948 Bytes

trunc

Truncate every element toward zero without rounding.

API

Numeric.math.trunc(value)

Applies the truncation across nested numeric inputs.

  • Parameters:
    • value: Scalar, vector, or matrix input values
  • Returns: Truncated values matching the input nesting shape
  • NumPy: Equivalent to np.trunc.

Examples

Truncate a scalar

import Numeric from '@neabyte/numerix'

const value = Numeric.math.trunc(1.9)

console.log(value)
// 1

Truncate a negative scalar

import Numeric from '@neabyte/numerix'

const value = Numeric.math.trunc(-1.9)

console.log(value)
// -1

Truncate a vector

import Numeric from '@neabyte/numerix'

const values = Numeric.math.trunc([1.9, -1.9])

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

Truncate a matrix

import Numeric from '@neabyte/numerix'

const values = Numeric.math.trunc([[1.9, 2.1], [-3.7, 4.2]])

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