---
title: RShiftC
description: "向量右移，包含8u，16u，16s，32s四种数据类型。右移会保留有符号整数的符号位，并从左侧填符号位。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_hmpp_06_0122.html
sourcePath: /source/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_hmpp_06_0122.html
indexId: ce0972097cb482698a62b829419f9b5f5092323bb6d56396517a8fdbe6aa088677
---
# RShiftC

向量右移，包含8u，16u，16s，32s四种数据类型。右移会保留有符号整数的符号位，并从左侧填符号位。

函数接口声明如下：

整型数的左移：

HmppResult HMPPS_RShiftC_8u(const uint8_t* src, int32_t val, uint8_t* dst, int32_t len);

HmppResult HMPPS_RShiftC_16u(const uint16_t* src, int32_t val, uint16_t* dst, int32_t len);

HmppResult HMPPS_RShiftC_16s(const int16_t* src, int32_t val, int16_t* dst, int32_t len);

HmppResult HMPPS_RShiftC_32s(const int32_t* src, int32_t val, int32_t* dst, int32_t len);

HmppResult HMPPS_RShiftC_8u_I(int32_t val, uint8_t* srcDst, int32_t len);

HmppResult HMPPS_RShiftC_16u_I(int32_t val, uint16_t* srcDst, int32_t len);

HmppResult HMPPS_RShiftC_16s_I(int32_t val, int16_t* srcDst, int32_t len);

HmppResult HMPPS_RShiftC_32s_I(int32_t val, int32_t* srcDst, int32_t len);

#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| src | 指向输入向量的指针。 | 非空 | 输入 |
| dst | 指向左移后输出向量的指针。 | 非空 | 输出 |
| srcDst | 指向原址操作向量的指针。 | 非空 | 输入/输出 |
| val | 左移位数。 | 非负 | 输入 |
| len | 向量长度。 | (0, INT\_MAX] | 输入 |


#### 返回值

- 成功：返回HMPP_STS_NO_ERR。
- 失败：返回错误码。


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| HMPP\_STS\_NULL\_PTR\_ERR | src，dst或srcDst为空指针。 |
| HMPP\_STS\_SIZE\_ERR | len小于或等于0。 |
| HMPP\_STS\_SHIFT\_ERR | val小于0。 |


#### 示例

```
#define BUFFER_SIZE_T 9
void RShiftCExample()
{
uint8_t src[BUFFER_SIZE_T] = {0, 1, 2, 3, 4, 5, 6, 7, 255};
uint8_t dst[BUFFER_SIZE_T] = {};
int32_t i;
HmppResult result = HMPPS_LShiftC_8u(src, 1, dst, BUFFER_SIZE_T);
printf("result = %d \ndst =", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (i = 0; i < BUFFER_SIZE_T; i++) {
printf("%d ", dst[i]);
}
}
```

运行结果：

```
result = 0
dst = 0 2 4 6 8 10 12 14 254
```
