You are not logged in. Please login at to post your questions!


What this line means?

I found this line written in one of the solution I went through a solution

//some call to a function was done here

I don't know meaning of this line, is it a check for even/odd, please explain and if possible mention any link where this bitwise operators tricks and tips are given??

asked 24 Jun '14, 20:42

keyser21's gravatar image

accept rate: 0%

It is the shorthand notation of P=P>>1 . >> is the right shift operator .

x>>y causes the binary representation of x to be shifted by the y digits to the right .

In the example you asked it is dividing the number by 2 and assigning to the number back .

For more information use : Right and Left Shift operator


answered 24 Jun '14, 21:02

the65bit's gravatar image

accept rate: 13%

but if an assigning operation is done in if statement, wont it evaluate to true always ??

(24 Jun '14, 22:47) brobear19952★

Yes, till the number becomes zero..For e.g 60, 30, 15, 7, 3, 1, 0.

(24 Jun '14, 22:53) asimali2464★

It won`t be to true always , it will evaluate to the value of the variable . For example in this case after the assignment is done it will become , if (p) , and it be True if p is not zero and false otherwise .

(24 Jun '14, 23:04) the65bit4★

Here, it checks for the number to be anything other than 0 and 1.

(25 Jun '14, 06:32) p00r3★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 24 Jun '14, 20:42

question was seen: 769 times

last updated: 25 Jun '14, 06:32