Rate This Document
Findability
Accuracy
Completeness
Readability

v?modf

Interface Definition

C interface:

void vsmodf(const int len, const float* src, float* dst1, float* dst2);

void vdmodf(const int len, const double* src, double* dst1, double* dst2);

Parameters

Parameter

Type

Description

Input/Output

len

Integer

Number of elements in the input vector.

If len ≤ 0, the system displays a message indicating that the value of len is invalid.

Input

src

  • Single-precision floating-point type for vsmodf
  • Double-precision floating-point type for vdmodf

Input vector src with length len.

If the pointer is null, the system prompts a null pointer error.

Input

dst1

  • Single-precision floating-point type for vsmodf
  • Double-precision floating-point type for vdmodf

Output vector dst1 with length len.

If the pointer is null, the system prompts a null pointer error.

Output

dst2

  • Single-precision floating-point type for vsmodf
  • Double-precision floating-point type for vdmodf

Output vector dst2 with length len.

If the pointer is null, the system prompts a null pointer error.

Output

Return Value

  • Each operation value returns the integer value and fraction part of x, which are stored in the memory pointed to by dst1 and dst2, respectively.
  • For special values, see the following table.

    Input Value (src)

    Output Value (dst1)

    Output Value (dst2)

    ±0

    ±0

    ±0

    +inf

    +inf

    +0

    -inf

    -inf

    -0

    nan

    nan

    nan

Dependency

C: "kvml.h"

Example

C interface:

    int i, len = 8; 
    float src[8] = {-1.5f, -0.0f, 0.0f, 1.0f, 1.5f, -INFINITY, INFINITY, NAN}; 
    float* dst1 = (float*)malloc(sizeof(float) * len); 
    if (dst1 == NULL) { 
        printf("Malloc Failed!\n"); 
        return 0;
    }
    float* dst2 = (float*)malloc(sizeof(float) * len); 
    if (dst2 == NULL) { 
        printf("Malloc Failed!\n"); 
        return 0;
    }
    vsmodf(len, src, dst1, dst2);

    /** 
     *  Output dst: 
     *     (-1.000000 -0.500000)(-0.000000 -0.000000)(0.000000 0.000000)(1.000000 0.000000)(1.000000 0.500000)(-inf -0.000000)(inf 0.000000)(nan nan)
     */