---
title: v?fmod
description: "C interface："
url: https://www.hikunpeng.com/document/detail/zh/kunpengaccel/math-lib/devg-kml/kunpengaccel_kml_0105.html
sourcePath: /source/zh/kunpengaccel/math-lib/devg-kml/kunpengaccel_kml_0105.html
indexId: 414bc6c1bd6c862588148ed229d8792e07400ea12bec4526febaf605e40a6d1468
---
# v?fmod

#### 接口定义

C interface：

void vsfmod(const int len, const float* src1, const float* src2, float* dst);

void vdfmod(const int len, const double* src1, const double* src2, double* dst);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| len | 整型数 | 表示输入向量的元素个数。 len≤0时会提示len无效并返回。 | 输入 |
| src1 | 在vsfmod中是单精度浮点类型。 在vdfmod中是双精度浮点类型。 | 输入向量src1，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输入 |
| src2 | 在vsfmod中是单精度浮点类型。 在vdfmod中是双精度浮点类型。 | 输入向量src2，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输入 |
| dst | 在vsfmod中是单精度浮点类型。 在vdfmod中是双精度浮点类型。 | 输出dst，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输出 |


#### 输出结果

- 每一个运算值返回向量的浮点余数，计算公式为fmod(x, y) = x - trunc(x/y) * y。
- 其他特殊值参考如下说明。| 输入值（src1） | 输入值（src2） | 输出值（dst） |
| --- | --- | --- |
| any | ±nan | nan |
| any | ±0 | nan |
| ±inf | any | nan |
| ±nan | any | nan |


#### 依赖

C: "kvml.h"


#### 示例

C interface：```
#define N 4
    const float src1[N] = {-8.0f, 25.0f, +INFINITY, -0.0f};
    const float src2[N] = {6.2f, -4.3f, -192.4, -3.1f};
    float dst[N] = {0};

    vsfmod(N, src1, src2, dst);
    printFArr("input1:", N, src1);
    printFArr("input2:", N, src2);
    printFArr("output:", N, dst);
 
    /** 
     *  input1: -8.000   25.000      inf   -0.000 
     *  input2:  6.200   -4.300 -192.400   -3.100
     *  output: -1.800    3.500      nan   -0.000
     */
```
