Operator RND

Operator Library: Arithmetics

運算子 RND 執行具備進位捨去與剪裁至輸出 Bit Width 功能的右移運算。 要進位捨去的位元數透過參數 bits2Round 指定。

所實作的進位捨去方法為四捨五入(遠離零)。色彩分量會分別進行進位捨去。

範例

  • Input = 4 Bit unsigned, Input Value = 7, bits2Round = 2

    Output = 2 Bit unsigned, Output Value = 2

  • Input = 5 Bit signed, Input Value = -13, bits2Round = 2

    Output = 3 Bit signed, Output Value = -3

  • Input = 4 Bit unsigned, Input Value = 15, bits2Round = 2

    Output = 2 Bit unsigned, Output Value = 3 注意:輸出已被剪裁至最大可能值。

I/O Properties

Property Value
Operator Type O
Input Link I, data input
Output Link O, data output

支援的 Link 格式

Link Parameter Input Link I Output Link O
Bit Width [1, 64] 無符號,[2, 64] 有符號 自動1
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
Type static parameter
Default 0
Range

[0, BitWidth(I)-1](針對無號數)

(BitWidth(I) - bits2Round > 1)(針對有號數)

此參數定義輸入向右位移的位元數。

使用範例

以下範例展示了運算子 RND 的使用方式: