5 views

Uploaded by Sridhar Muthoju

how the bit conversion will take by bitwise operation

save

You are on page 1of 3

com Bit manipulation and shifting is the process of taking data and toying with the binary representation of the number (the basic 1s and 0s that it is made of). Bit operations in C/C++ are carried out with the following operators:

-----------------------------------------------------------| Operator Definition | -----------------------------------------------------------| || | Bitwise OR (Not to be conused with ||) | |& | Bitwise AND (Not to be confused with &&) | |^ | XOR (Exclusive OR) | | << | Shift left | | >> | Shift right | | ~ | Unary (One's compliment) | ------------------------------------------------------------

OR is fairly simple: The OR operator ( | ) compares two bits and returns true ( 1 ) if either or both bits are set to true.

A=1;B=2;C=A|B; A 00000001 B 00000010 ----------C 00000011

It basically just adds the binary of the numbers. It doesn't actually add the numbers though: remember that. AND is just as easy: The AND operator ( & ) compares two bits and returns true ( 1 ) only if both bits are set to true.

A=1;B=3;C=A&B; A 00000001 B 00000011 ----------C 00000001

See what it did? Everywhere there was a 1 in the first string and the second string, there was a 1 in the resulting string. XOR is slightly trickier: The XOR operator ( ^ ) compares two bits and returns true ( 1 ) if and only if one of the bits is set to true. (1 ^ 3)

A=1;B=3;C=A^B; A 00000001 B 00000011 -----------

htm#&panel1-2 . is that the numbers don't carry! soo: 000000001 >> 1 = 00000000 (the result is not 10000000 as you might expect) And remember I wrote the numbers out in binary instead of the actual numbers you'd put in there.vignanam. you don't write the numbers in binary -. it became a zero.C 00000010 Anywhere there was a 1 in both numbers.B=~A. http://www. UNARY is the easiest.org/telugu. ( 00000011 is 3. and 00000001 is 1 binary ) So remember.you write them in decimal to use the bit operators. 00000010 is 2. It basically means binary opposite: (~1) A=1. It moves the numbers down by the number you place to the right. >> is actually the quickest way to divide by 2 << is actually the quickest way to multiply by 2 Another thing about shifts. A 00000001 ----------B 11111110 << and >> (shift left and right) are incredibly simple. and they are used the most: 000000010 >> 1 = 000000001 000000001 << 1 = 000000010 It basically goes like this: number >> amount to shift by.

- PT2262 PT2272 With Arduino and r06aUploaded byCarls Guiovani Guirrardelli Vega
- Byte of Python by Ch. SwaroopUploaded byRavi Akella
- 88 86 I ProgrammingUploaded byankuragarwal70
- NT00121ENUploaded byxor_45
- DeltaV SIS Module - Level ParametersUploaded bymacconnor
- de_Jonge+van_der_Loo-Introduction_to_data_cleaning_with_RUploaded byTuanNguyen
- DevinetManual1794-IB8SUploaded byAlberto Cantero
- 9840 Intelligent IndicatorUploaded byWim Andre
- UntitledUploaded bysahithiramu
- 091671755481mUploaded byArmando Galindo
- Misa InsideUploaded bysfofoby
- Copy of RRC StatesUploaded byAmgad
- API in VB Dot NET - MikroTik WikiUploaded byraphonjuga
- Java Script CourseUploaded byapi-3695674
- 37542Uploaded byAnderson Rocha
- LcdUploaded byHeidi Watkins
- lab4_blogUploaded byTeja Ananthasetty
- Primer 1Uploaded byejoaomelchiors
- RCS-974AG通信规约说明 (2)Uploaded bymahesh
- JEP106AV (SJEPtandard Manufacturer’s Identification Code)Uploaded by2r323ffff2f2fefdfdfdfdfdfdfdf
- An R Function for the Blau Index of DiversityUploaded byTsige Bayrau
- plus 10 squares-1Uploaded byapi-395946560
- Templates ProgrammingUploaded byMìrägé Σ∞ Ãçê
- Mod BusUploaded byWilson Barco M
- Application FlashCardUploaded byM Namir Hasan
- FIOA0402UUploaded bymcsec
- 11b PHP ProgrammingUploaded byEric Nilo
- Stld Notes Unit-2Uploaded byArun Dasari
- Temperature ConvertorUploaded bySrinivas Vaddanam
- ASPDay6Uploaded bySrikanth

- La Mujer en La Época ContemporáneaUploaded byDanny Fernández
- Terapia Cognitiva ConductualUploaded bymaker09
- Contrato de manutenção de softwareUploaded byUec Itabuna
- Taller de Investigacion 1Uploaded byHerdez
- CD Trabajo Colaborativo 2 100410 104.PDFUploaded byHeiler Martin
- Quiz II and AnswerUploaded byIni Arum
- Vietnam a Natural HistoryUploaded byDaisy
- Best+Of+MASSUploaded byAlbert King
- Module 01-Fall of Empire.Uploaded byRanuka Gamage
- MomentumUploaded bySteve
- Antologia Microypara LeoUploaded byJezzi Pedro Andrade
- VIOLACION 25Uploaded byDuncan Vanegas
- Mario ZárateUploaded byMario Zárate
- An-106 Antenna FactorUploaded byBreen Len
- meycorUploaded byoutlookleiva
- EC2402Uploaded byJesse Vincent
- Instalacion de Una ComputadoraUploaded byYeira Quijada Corro
- Problems Based on Sampling DistributionsUploaded byfdsfsfsf
- Strategic ManagementUploaded byrajiv kumar
- US Food and Drug Administration: 03d-0061-emc0005-01-vol2Uploaded byFDA
- La Revolución IndustrialUploaded byvenellopeok
- puente de spaguettiUploaded byJosué Tovar Enciso
- SQL by Avanti Expt 5Uploaded byganeshjorvekar
- Slovay 1927Uploaded byk6may
- Ensaio_e_certificaçao_das_máquinas_para_a_semeadura.pdfUploaded byMarcus Drago
- guia para un proyecto ejemploUploaded byapi-250766223
- GuiaUploaded byBastiao
- Ds Mechanical Presentation RsUploaded byvarun095328
- Fundamentos Análisis VectorialUploaded byElvis Santillan
- Tipos de AceitesUploaded byAlberto Costilla Garcia