Dart Tutorial

Dart Tutorial Single-Page Application Architecture Dart Features Dart Installation Guide Dart Basic Program Dart Syntax Dart Keywords Dart Variables Dart Comments Dart Standard Input Output Dart Important Concepts

Data Types

Built-in Data Types Numbers Strings Booleans Lists Sets Maps Runes and Graphemes Symbols Enumerations Constants Queues

Other data types

Objects Future and stream Iterable Miscellaneous types

OPERATORS

Precedence and associativity Arithmetic operators Equality and Relational operators Type Test Operators Assignment Operators Logical Operators Bitwise and Shift Operators Miscellaneous operators

Control Flow Statements

Introduction If statement If-else statement If-else-if statement Loops Switch and case Dart Break And Continue Assert In Dart

FUNCTIONS

Dart function Types of Functions Anonymous function main( ) function Lexical scope and closure Recursion Common Collection Methods

Object Oriented Concepts

Dart Object-Oriented Concepts Dart Classes Dart Constructors Dart This Keyword Dart Super Keyword Static Members Method Overriding Dart Interfaces Inheritance Dart Abstract Classes Dart Builder Classes Dart Callable Classes

Dart Type System

Dart Type System Dart Soundness Dart Type Inference

MISCELLANEOUS

Dart Isolates Dart Typedef Dart Metadata Dart Packages Dart Generics Dart Generators Dart Concurrency Dart Unit Testing Dart Html Dom Dart URIs Dart Extends, With and Implements Keywords Dart Optional Parameters Rust Vs Dart C++ vs Dart Golang Vs Dart Dart Basics Exception Handling

Dart Bitwise and Shift Operators

The Bitwise operators are the operators that perform different operations bit by bit on the value of the two operands.

List of Bitwise Operators in Dart

Sr.

Operators

Description

1.

& ( Binary AND )

It returns 1 if and only if both bits are 1, and returns 0 if either one of them is 0.

2.

| ( Binary OR )

It returns 1 if any of the bits is 1, and returns 0 if and only if both bits are 0.

3.

^ ( Binary XOR )

It returns 1 if both bits are different, and returns 0 if both bits are same.

4.

~ ( 1’s Complement )

It returns the reverse of the bit. If the bit is 0 then the complement will be 1.

5.

<< ( Shift left )

The value of the left operand shifts to the left by the number of bits present in the right of the operator.

6.

>> ( Shift right )

The value of the right operand shifts to the right by the number of bits present in the left of the operator.


Program

void main( )

{

  print( " Bitwise Operators \n " ) ;

  var a  = 50 ;

  var b = 40 ;

  var c = 0 ;

  // Bitwise AND Operator

  var res1 = a & b ;

  print( " a & b = " ) ;

  print( res1 ) ;

  // Bitwise OR Operator

  var res2 = a | b ;

  print( " \n a | b = " ) ;

  print( res2 ) ;

  // Bitwise XOR

  var res3 = a ^ b ;

  print( " \n a ^ b =  " ) ;

  print( res3 ) ;

  // Complement Operator

  var res4 = ~a ;

  print( " \n ~a = " ) ;

  print( res4 ) ;

  // Binary left shift Operator

  var res5 = a << 2 ;

  print( " \n c << 1 = " ) ;

  print( res5 ) ;

  // Binary right shift Operator

  var res6 = a >> 2 ;

  print( " \n c >> 1 = " ) ;

  print( res6 ) ;

}

Output

 Bitwise Operators

a & b =

32

a | b =

58

a ^ b =

26

~a =

4294967245

c << 1 =

200

c >> 1 =

12