Bit-wise XOR - MATLAB bitxor (2024)

Bit-wise XOR

collapse all in page

Syntax

C = bitxor(A,B)

C = bitxor(A,B,assumedtype)

objout = bitxor(netobj1,netobj2)

Description

example

C = bitxor(A,B) returnsthe bit-wise XOR of A and B.

example

C = bitxor(A,B,assumedtype) assumesthat A and B are of assumedtype.

objout = bitxor(netobj1,netobj2) returnsthe bit-wise XOR of the .NET enumeration objects netobj1 and netobj2.

Examples

collapse all

Truth Table

Open Live Script

Create a truth table for the logical XOR operation.

A = uint8([0 1; 0 1]);B = uint8([0 0; 1 1]);TTable = bitxor(A, B)

bitxor returns 0 if both bit-wise inputs are equal.

Negative Values

Open Live Script

MATLAB® encodes negative integers using two's complement. For example, to find the two's complement representation of -5, you take the bit pattern of the positive version of the number (00000101), swap each bit (11111010), and then add 1 to the result (11111011).

Therefore, the bit-wise XOR of -5 (11111011) and 6 (00000110) is -3 (11111101).

a = -5;bitget(a,8:-1:1,'int8')
ans = 1×8 1 1 1 1 1 0 1 1
b = 6;bitget(b,8:-1:1,'int8')
ans = 1×8 0 0 0 0 0 1 1 0
c = bitxor(a,b,'int8')
c = -3
bitget(c,8:-1:1,'int8')
ans = 1×8 1 1 1 1 1 1 0 1

Input Arguments

collapse all

A,BInput values
scalars | vectors | matrices | multidimensional arrays

Input values, specified as scalars, vectors, matrices, or multidimensionalarrays. Inputs A and B musteither be the same size or have sizes that are compatible (for example, A isan M-by-N matrix and B isa scalar or 1-by-N row vector).For more information, see Compatible Array Sizes for Basic Operations. A and B alsomust be the same data type unless one is a scalar double.

  • If A and B aredouble arrays, and assumedtype is not specified,then MATLAB® treats A and B asunsigned 64-bit integers.

  • If assumedtype is specified, thenall elements in A and B musthave integer values within the range of assumedtype.

Data Types: double | logical | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

assumedtypeAssumed data type of A and B
'uint64' | 'uint32' | 'uint16' | 'uint8' | 'int64' | 'int32' | 'int16' | 'int8'

Assumed data type of A and B,specified as 'uint64', 'uint32', 'uint16', 'uint8', 'int64', 'int32', 'int16',or 'int8'.

  • If A and B aredouble arrays, then assumedtype can specify anyvalid integer type, but defaults to 'uint64'.

  • If A and B areinteger type arrays, then assumedtype must specifythat same integer type.

Data Types: char | string

netobj1, netobj2Input values
.NET enumeration objects

Input values, specified as .NET enumeration objects. You mustbe running a version of Windows® touse .NET enumeration objects as input arguments.

bitxor is an instance method for MATLAB enumerationobjects created from a .NET enumeration.

Output Arguments

collapse all

C — Bit-wise XOR result
array

Bit-wise XOR result, returned as an array. C isthe same data type as A and B.

  • If either A or B isa scalar double, and the other is an integer type, then C isthe integer type.

objout — Bit-wise XOR result
.NET enumeration object

Bit-wise XOR result, returned as a .NET enumeration objects.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

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

Version History

Introduced before R2006a

See Also

bitand | bitcmp | bitget | bitor | bitnot | bitshift | bitset | intmax

Topics

  • Creating .NET Enumeration Bit Flags

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Bit-wise XOR - MATLAB bitxor (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Bit-wise XOR - MATLAB bitxor (2024)

References

Top Articles
Whole Hog Sports Recruiting
Interest rates are coming down in Europe. The Fed won’t follow yet | CNN Business
Nerdwallet Chase
Smoothie Operator Ruff Ruffman
What Is the Z-Track Injection Method?
Busted Newspaper Longview Texas
Tampa Lkq Price List
Nala Ahegao
Generation Zero beginner’s guide: six indispensable tips to help you survive the robot revolution
Gt7 Roadster Shop Rampage Engine Swap
Telegram X (Android)
How Nora Fatehi Became A Dancing Sensation In Bollywood 
Buhl Park Summer Concert Series 2023 Schedule
San Antonio Busted Newspaper
Faotp Meaning In Text
Nsu Occupational Therapy Prerequisites
Ttw Cut Content
Does Publix Pharmacy Accept Sunshine Health
Best Builder Hall 5 Base
Myzmanim Highland Park Nj
Uc My Bearcat Network
Carly Carrigan Family Feud Instagram - Carly Carrigan Home Facebook : The best gifs for carly family feud.
Orlando Magic Account Manager
Julie Green Ministries International On Rumble
895 Area Code Time Zone
Aogf Causes.benevity
Only Murders In The Building Wiki
Карта слов и выражений английского языка
2005 Chevy Colorado 3.5 Head Bolt Torque Specs
Emuaid Lawsuit
How Much Is 10000 Nickels
Central Valley growers, undocumented farmworkers condemn Trump's 'emergency'
Etfh Hatchery
Sessional Dates U Of T
Central Valley growers, undocumented farmworkers condemn Trump's 'emergency'
Bianca Censo
Erie Pa Craigslist
Huskersillustrated Husker Board
Fired Dies Cancer Fired Qvc Hosts
NO CLUE: deutsche Übersetzung von NCT 127
Crossword Answers, Crossword Solver
The Nun 2 Ending Explained, Summary, Cast, Plot, Review, and More
Unblocked Games Shooters
Lowlifesymptoms Twitter
Lifetime Benefits Login
358 Edgewood Drive Denver Colorado Zillow
Jane Powell, Spirited Star of Movie Musicals ‘Royal Wedding,’ ‘Seven Brides,’ Dies at 92
Welcome to Predator Masters -- Hunting the Hunters
Grayson County Craigslist
9372034886
What stores are open on Labor Day 2024? A full list of where to shop
Barotrauma Game Wiki
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 6517

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.