我要评分
获取效率
正确性
完整性
易理解

v?trunc

Compute the integer value of the input vector rounded towards 0 and return the value as a floating-point number.

Interface Definition

C interface:

void vstrunc(const int len, const float* src, float* dst);

void vdtrunc(const int len, const double* src, double* dst);

Parameters

Parameter

Type

Description

Input/Output

len

Integer

Number of elements in the input vector.

If len ≤ 0, an invalid parameter error is reported and the function returns.

Input

src

  • Single-precision floating-point type for vstrunc
  • Double-precision floating-point type for vdtrunc

Input vector src with length len.

If the pointer is null, a null pointer error is reported and the function returns.

Input

dst

  • Single-precision floating-point type for vstrunc
  • Double-precision floating-point type for vdtrunc

Output vector dst with length len.

If the pointer is null, a null pointer error is reported and the function returns.

Output

Return Value

  • The result of x rounded towards 0 is returned for each operation value.
  • For special values, see the following table.

    Input Value (src)

    Output Value (dst)

    +0

    +0

    -0

    +0

    +inf

    +inf

    -inf

    -inf

    nan

    nan

Dependencies

C: "kvml.h"

Examples

C interface:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
float src[LEN] = {1.1f, -2.1f, INFINITY, NAN};
float* dst = (float*)malloc(sizeof(float) * LEN);
if (dst == NULL) {
    printf("Malloc Failed!\n");
    return;
}
vstrunc(LEN, src, dst);
/**
 *  Output dst:
 *     1.0  -2.0  INFINITY  nan
 *
 */