Javatpoint Logo
Javatpoint Logo

Numpy trunc()

This function returns the truncated value of the input array elements. The truncated value t of input value x is the nearest integer which is closer to zero than x.

The fractional part of the input number is discarded by this function.

Syntax

Parameters

  1. array: Array elements whose truncated values are to be returned.

Return

An array containing the truncated values are to be returned.

Example

Output:

Input array: [0.23, 0.09, 1.2, 1.24, 9.99]
Output array: [0. 0. 1. 1. 9.]
Input array: [145.23, 0.12, 12.34, 123]
Output array: [145.   0.  12. 123.]





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA