Ruby | Integer >> method
Last Updated :
19 Mar, 2024
The >> is an inbuilt method in Ruby returns the number which is shifted N times to the right. The resultant number is int(num / (2^N)).
Syntax: num >> N
Parameters: The function accepts no parameter.
Return Value: It returns int(num / (2^N)).
Example 1:
num1 = 6
num2 = 1
print num1 >> num2
|
Output:
3
Example 2:
num1 = 2
num2 = 2
print num1 >> num2
|
Output:
0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...