Operator RND

Operator Library: Arithmetics

運算子 RND 執行右移運算,並進行四捨五入及截斷至輸出位元寬度。 需進行四捨五入的位元數由參數bits2Round 指定。

「離零方向半舍入」是所採用的舍入方法。色彩成分會分別進行舍入。

範例

  • 輸入 = 4 位元無符號,輸入值 = 7,bits2Round = 2

    輸出 = 2 位元無符號數,輸出值 = 2

  • 輸入 = 5 位元有符號數,輸入值 = -13,bits2Round = 2

    輸出 = 3 位元有符號數,輸出值 = -3

  • 輸入 = 4 位元無符號數,輸入值 = 15,bits2Round = 2

    輸出 = 2 位元無符號,輸出值 = 3 註:輸出值已被裁剪至最大可能值。

I/O Properties

Property Value
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

輸出的位元寬度等於輸入位元寬度減去 `bits2Round` 參數的數值。

Parameters

bits2Round
Type 靜態參數
Default 0
Range

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

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

此參數定義輸入資料向右移位多少位元。

Examples of Use

以下範例展示了運算子 RND 的用法: