Operator CastBitWidth

The operator CastBitWidth changes the bit width by selecting the lower bits of the input. If the output bit width is greater than the input bit width, the value is kept i.e. bit are added to the most significant bits. A sign extension is performed for signed value. If the output bit width is less than the input bit width, the most significant bits are discarded. The value changes to

i.e. only the remaining bits are used. Output bit width is defined by .

For color values, each component is processed individually.

Use the operator with care. Only discard bits if you know you will not require them. The operator might destroy your values.

Input Bit Width Input Value Arithmetic Output Bit Width Output Value Comment
Decimal Binary Decimal Binary
5 10 01010 unsigned 4 10 1010 value is kept
5 10 01010 unsigned 3 2 010 value is changed
5 10 01010 signed 6 10 001010 value is kept
5 -10 10110 signed 6 -10 110110 value is kept, sign extension
5 10 01010 signed 4 -6 1010 value is changed
5 -10 10110 signed 4 6 0110 value is changed

Table 20. Examples


I/O Properties

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

Supported Link Format

Link Parameter Input Link I Output Link O
Bit Width [1, 64]1 [1, 64]2
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, VALT_SIGNAL} 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

The range of the input bit width is [1, 64]. For signed inputs, the range is [2, 64]. For unsigned color inputs, the range is [3, 63] and for signed color, the range is [6, 63].

2

The range of the output bit width is [1, 64]. For signed outputs, the range is [2, 64]. For unsigned color outputs, the range is [3, 63] and for signed color, the range is [6, 63].

Parameters

None

Examples of Use

The use of operator CastBitWidth is shown in the following examples: