v?modf
Compute a truncated integer value and the remaining fraction part for the input vector.
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, an invalid parameter error is reported and the function returns. |
Input |
src |
|
Input vector src with length len. If the pointer is null, a null pointer error is reported and the function returns. |
Input |
dst1 |
|
Output vector dst1 with length len. If the pointer is null, a null pointer error is reported and the function returns. |
Output |
dst2 |
|
Output vector dst2 with length len. If the pointer is null, a null pointer error is reported and the function returns. |
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
Dependencies
C: "kvml.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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) */ |