# Multiplication Operators

The multiplication operators can only accept and return data types from the I[s|u]16vec4 or I[s|u]16vec8 classes, as shown in the following example.

Syntax Usage for Multiplication Operators

Explicitly convert B to Is16vec4.

`Is16vec4 A,C;`

`Iu32vec2 B;`

`C = A * C;`

`C = A * (Is16vec4)B;`

Return nearest common ancestor type, I16vec4

`Is16vec4 A;`

`Iu16vec4 B;`

`I16vec4 C;`

`C = A + B;`

The mul_high and mul_add functions take Is16vec4 data only.

`Is16vec4 A,B,C,D;`

`C = mul_high(A,B);`

`D = mul_add(A,B);`

Multiplication Operators with Corresponding Intrinsics

Symbols | Syntax Usage | Intrinsic
--- | --- | ---
* | *= | R = A * B R *= A | _mm_mullo_pi16 _mm_mullo_epi16
mul_high | N/A | `R = mul_high(A, B)` | _mm_mulhi_pi16 _mm_mulhi_epi16
mul_add | N/A | `R = mul_high(A, B)` | _mm_madd_pi16 _mm_madd_epi16

The multiplication return operators always return the nearest common ancestor as listed in the table that follows. The two operands must be 16 bits in size, otherwise you must explicitly indicate typecasting.

Multiplication Operator Overloading

R | Mul | A | B
--- | --- | --- | ---
`I16vec4 R` | * | `I[s|u]16vec4 A` | `I[s|u]16vec4 B`
`I16vec8 R` | * | `I[s|u]16vec8 A` | `I[s|u]16vec8 B`
`Is16vec4 R` | mul_add | `Is16vec4 A` | `Is16vec4 B`
`Is16vec8` | mul_add | `Is16vec8 A` | `Is16vec8 B`
`Is32vec2 R` | mul_high | `Is16vec4 A` | `Is16vec4 B`
`Is32vec4 R` | mul_high | `s16vec8 A` | `Is16vec8 B`

The following table shows the return values and data type assignments for operands of the multiplication operators with assignment. All operands must be 16 bytes in size. If the operands are not the right size, you must use an explicit typecast.

Multiplication with Assignment

Return Value (R) | Left Side (R) | Mul | Right Side (A)
--- | --- | --- | ---
`I[x]16vec8` | `I[x]16vec8` | *= | `I[s|u]16vec8 A;`
`I[x]16vec4` | `I[x]16vec4` | *= | `I[s|u]16vec4 A;`

Parent topic: Integer Vector Classes