Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
Right Shift (>>) Bitwise Operator in JavaScript
Next article icon

What is JavaScript >>> Operator and how to use it ?

Last Updated : 19 Jun, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

The JavaScript >>> represents the zero-fill right shift operator. It is also called the unsigned right-bit shift operator. It comes under the category of Bitwise operators. Bitwise operators treat operands as 32-bit integer numbers and operate on their binary representation. 

Zero-fill right shift (>>>) operator: It is a binary operator, where the first operand specifies the number and the second operand specifies the number of bits to shift. The operator shifts the bits of the first operand by a number of bits specified by the second operand. The bits are shifted to the right and those excess bits are discarded, while 0 bit is added from the left. As the sign bit becomes 0, the operator ( >>> ) returns a 32-bit non-negative integer. 

Example:

Input: A = 6 ( 00000000000000000000000000000110 ) B = 1 ( 00000000000000000000000000000001 )  Output: A >>> B = 3 ( 00000000000000000000000000000011 )

Syntax:

result = expression1 >>> expression2

Difference between >>> and >>: The difference between these two is that the unsigned zero-fill right shift operator (>>>) fills with zeroes from the left, and the signed right bit shift operator (>>) fills with the sign bit from the left, thus it maintains the sign of the integer value when shifted. 

Example: This example implements the use of >>> operator:

JavaScript
console.log("For non negative number:<br>"); let a = 12;  // Shift right two bits let b = 2; console.log("a = " + a + " , b = " + b); console.log("<br>a >>> b = " + (a >>> b) + '<br>');  console.log("<br>For negative number:<br>"); let a = -10;  // Shift right two bits let b = 3; console.log("a = " + a + " , b = " + b); 

Output
For non negative number:<br> a = 12 , b = 2 <br>a >>> b = 3<br> <br>For negative number:<br> a = -10 , b = 3

Explanation: For non-negative numbers, zero-fill right shift (>>>) and sign-propagating right shift (>>) gives the same output. For example, 9 >>> 2 and 9 >> 2 give the same result i.e. 2. But for negative numbers, -9 >>> 2 gives 1073741821, and -9 >> 2 gives -3 as output.

Case 1: non-negative number     12 (base 10): 00000000000000000000000000001100 (base 2)                    --------------------------------     12 >>> 2 (base 10): 00000000000000000000000000000011 (base 2)     = 3 (base 10)  Case 2: negative number     -10 (base 10): 11111111111111111111111111110110 (base 2)                     --------------------------------     -10 >>> 3 (base 10): 00011111111111111111111111111110 (base 2)     = 536870910 (base 10) 

Next Article
Right Shift (>>) Bitwise Operator in JavaScript

G

g_ragini
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • javascript-operators
  • JavaScript-Questions

Similar Reads

  • What does OR Operator || in a Statement in JavaScript ?
    JavaScript is a dynamic programming language that allows developers to write complex code with ease. One of the fundamental concepts in JavaScript is the use of operators, which are symbols that perform operations on one or more values. One such operator is the || (logical OR) operator, which can be
    6 min read
  • What is (~~) "double tilde" operator in JavaScript ?
    This is a special kind of operator in JavaScript. To understand the double tilde operator, first, we need to discuss the tilde operator or Bitwise NOT. The (~) tilde operator takes any number and inverts the binary digits, for example, if the number is (100111) after inversion it would be (011000).
    3 min read
  • AND(&) Bitwise Operator in JavaScript
    JavaScript Bitwise AND(&) operator is used to compare two operands by performing an AND operation on the individual bits and returning 1 only if both the bits are one. The AND(&) Operator has a lot of real-world applications and the most famous one is to check whether a number is even or odd
    2 min read
  • Bitwise AND Assignment (&=) Operator in JavaScript
    The Bitwise AND Assignment Operator is represented by "&=". This operator uses the binary representation of both operands and performs the bitwise AND operation and then assigns the result to the left operand. This can also be explained as applying the logical AND operation to the first operand
    1 min read
  • Right Shift (>>) Bitwise Operator in JavaScript
    JavaScript bitwise right shift operator is used to operate on two operands where the left operand is the number and the right operand specifies the number of bits to shift towards the right. A copy of old leftmost bits is maintained and they have added again the shifting is performed. The sign bit i
    2 min read
  • What is the !! (not not) Operator in JavaScript?
    The !! (double negation) operator is a repetition of the unary logical "not" (!) operator twice. It is used to determine the truthiness of a value and convert it to a boolean (either true or false). Here’s how it works: The single ! (logical "not") inverts the truth value of a given expression:!fals
    2 min read
  • What does +_ operator mean in JavaScript ?
    Unary Operator: A unary operation contain only one operand. Here, the '+' unary plus operator converts its operand to Number type. While it also acts as an arithmetic operator with two operands which returns an addition result on calculation. JavaScript Identifiers: Javascript Identifiers are used t
    2 min read
  • Bitwise OR Assignment (|=) Operator in JavaScript
    The Bitwise OR Assignment Operator in JavaScript is represented by (|=). This operator is used to perform a bitwise OR operation on both operands and assign the result to the left operands. Syntax: a |= b Where - a = First operandb = Second operand Example 1: In this example, we will use basic numer
    2 min read
  • Bitwise XOR Assignment (^=) Operator in JavaScript
    The Javascript Bitwise XOR assignment is represented by (^=). It is used to perform a bitwise XOR operation on both operands and assign the result to the left operand. Syntax: a ^= b // a = a ^ b Where - a = First operandb = Second operand Example: In this example, we will perform the basic Bitwise
    2 min read
  • OR(|) Bitwise Operator in JavaScript
    JavaScript Bitwise OR(|) Operator is used to compare two operands by performing OR operation on individual bits of the operands and returns true even if one of the compared bits is 1. The OR Operator has vast applications and the most used one is combining bit values. The operation is represented by
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences