---
title: v?fmod
description: "矢量计算两个输入向量的浮点余数。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0106.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0106.html
indexId: 5058763a4b6aaff2a1fa07c661c6c8b5b8d0bc40d2ed99cc4d6f6854d771daac61
---
# 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
     */
```
