Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
"&" and ">>" number operator in C++?

I am trying to make a raycaster game in Javascript, and to do so, I am following this tutorial, which is written in C++.

My problem stems from trying to convert the following two lines to javascript:

int tx = (int)(texWidth * (floorX - cellX)) & (texWidth - 1);
color = (color >> 1) & 8355711; // make a bit darker

I don't know what the "&" and ">>" mean in those two lines. Is there an equivalent in Javascript?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

>> is the right bit-shift operator and & is the bitwise-and operator, both of them are available in JavaScript

about 4 years ago · Juan Pablo Isaza Report

0

The code directly translates to JS with the removal of the (int) typecast and the replacement of int with let/var/const.

let tx = (texWidth * (floorX - cellX)) & (texWidth - 1);    
color = (color >> 1) & 8355711; // make a bit darker 

& is the bitwise and, >> is the bitshift right, explained well here.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!