Main Content

bitxor

Bitwise XOR of two fi objects

Description

example

c = bitxor(a,b) returns the bitwise exclusive OR of fi objects a and b in fi object c.

The output is determined as follows:

  • Elements in the output array c are assigned a value of 1 when exactly one of the corresponding bits in the input arrays has a value of 1.

  • Elements in the output array c are assigned a value of 0 when the corresponding bits in the input arrays have the same value (e.g. both 1's or both 0's).

Note

This function only supports fi objects with fixed-point data types. To compute bitwise XOR of other data types, use the bitxor function.

Examples

collapse all

Find the bitwise exclusive OR of fi objects a and b.

a = fi(-28,1,6,0);
b = fi(12, 1, 6, 0);
c = bitxor(a,b)
c = 
   -24

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 6
        FractionLength: 0

To verify the result, examine the binary representations of a, b, and c.

binary_a = a.bin
binary_a = 
'100100'
binary_b = b.bin
binary_b = 
'001100'
binary_c = c.bin
binary_c = 
'101000'

Input Arguments

collapse all

Input fixed-point fi objects, specified as scalars, vectors, matrices, or multidimensional arrays. a and b must have the same dimensions unless one is a scalar.

The numerictype properties associated with a and b must be identical. If both inputs have an attached fimath object, their local fimath properties must be identical. If the numerictype is signed, then the bit representation of the stored integer is in Two's Complement representation.

Data Types: fi
Complex Number Support: Yes

Extended Capabilities

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced before R2006a

See Also

| | | |