Operator RND

Operator Library: Arithmetics

运算符 RND 执行带舍入和截断的右移操作,将结果输出到指定的 Bit Width。舍入的位数由参数 bits2Round 指定。

实现的舍入方法为远离零的半舍入(Round half away from zero)。颜色分量分别进行舍入。

示例

  • Input = 4 Bit 无符号,Input Value = 7,bits2Round = 2

    Output = 2 Bit 无符号,Output Value = 2

  • Input = 5 Bit 有符号,Input Value = -13,bits2Round = 2

    Output = 3 Bit 有符号,Output Value = -3

  • Input = 4 Bit 无符号,Input Value = 15,bits2Round = 2

    Output = 2 Bit 无符号,Output Value = 3 注意:输出已被截断至最大可能值。

I/O Property

Property 值
Operator Type O
Input Link I,数据输入
Output Link O,数据输出

Supported Link Format

Link Parameter Input Link I Output Link O
Bit Width [1, 64] 无符号,[2, 64] 有符号 auto1
Arithmetic {unsigned, signed} as I
Parallelism any as I
Kernel Columns any as I
Kernel Rows any as I
Img Protocol {VALT_IMAGE2D, VALT_LINE1D, VALT_PIXEL0D} as I
Color Format any as I
Color Flavor any as I
Max. Img Width any as I
Max. Img Height any as I

1

输出端的 Bit Width 为输入端 Bit Width 减去参数 bits2Round 的值。

参数

bits2Round
键入 static 参数
默认 0
范围

[0, BitWidth(I)-1](无符号)

(BitWidth(I) - bits2Round > 1)(有符号)

此参数定义输入向右移位的位数。

使用示例

以下示例展示了运算符 RND 的用法: