Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 978 Bytes

modf.md

File metadata and controls

62 lines (40 loc) · 978 Bytes

modf

Split values into their fractional and integral portions.

API

Numeric.math.modf(value)

Separates each value into its whole and fractional portions.

  • Parameters:
    • value: Scalar, vector, or matrix of input values
  • Returns: Fractional and integral parts for each input value
  • NumPy: Equivalent to np.modf.

Examples

Split one value into parts

import Numeric from '@neabyte/numerix'

const parts = Numeric.math.modf(3.75)

console.log(parts)
// [0.75,3]

Split a vector into parts

import Numeric from '@neabyte/numerix'

const parts = Numeric.math.modf([3.75, -2.5])

console.log(parts)
// [[0.75,-0.5],[3,-2]]

Split a whole value

import Numeric from '@neabyte/numerix'

const parts = Numeric.math.modf(3)

console.log(parts)
// [0,3]

Split a negative fractional value

import Numeric from '@neabyte/numerix'

const parts = Numeric.math.modf(-0.25)

console.log(parts)
// [-0.25,0]