Тёмный

Shift Operators in Java || Lesson 10 || Java Programming || Learning Monkey || 

Learning Monkey
Подписаться 55 тыс.
Просмотров 2,6 тыс.
50% 1

Shift Operators in Java
In this class, We discuss Shift Operators in Java.
The reader should have prior knowledge of bitwise operators. Click here.
Shift Operators:
Left Shift
Right Shift Holding sign
Right Shift Unsigned
Example:
int a= 10, b;
b= altlt1;
Here 1 means shift bits left side one time.
b=altlt2 means shift bits left side 2 times.
a=10, the binary value of 10 is 001010.
In our example, we are showing 6 bits. But in the system, 32 bits are assigned.
Left shift place zero in the least significant bit position.
The least significant bit is moved to the 2nd position.
The actual bit in the second position is moved to 3rd position.
Similarly, each bit is moved to one position left.
After leaving Shift one time, the output is saved in the variable b.
System.out.println(b); will display 20.
Important: Initial a = 10. After the left Shift, the value is 20.
one left Shift will increase the value multiplied by 2.
agtgt2 will have a value of 40.
Each left shift operation will double the value.
Right Shift:
The right Shift starts from the most significant bit.
a=10, b;
b = agtgt1 will right shift one bit.
The most significant bit will be copied to maintain the sign.
The most significant bit is moved to the next position, and so on.
The right shift operation will make the value divisible by 2.
a=10;
b = agtgt1 will have a value of 5.
b= agtgt2 will have a value of 2.
right, Shift two times.
First time 10/2 = 5
The second time 5/2 = 2.5, but the Shift maintains the floor value.
The floor value of 2.5 is 2
Similarly, a floor value of -2.5 is -3.
The division maintains the floor value all the time.
Right Shift
This right shift operation will place zero in the most significant bit position.
After that, Shift the most significant bit to one bit right, and so on.
Here we are not maintaining the sign of the number.
Link for playlists:
/ @learningmonkey
Link for our website: learningmonkey.in
Follow us on Facebook @ / learningmonkey
Follow us on Instagram @ / learningmonkey1
Follow us on Twitter @ / _learningmonkey
Mail us @ learningmonkey01@gmail.com

Опубликовано:

 

30 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 12   
@btseditor609
@btseditor609 3 месяца назад
good sir ji
@ajaybabu4037
@ajaybabu4037 5 дней назад
Super bro well explained ❤😊
@LearningMonkey
@LearningMonkey 4 дня назад
Have a great learning in CSE
@bishmie708
@bishmie708 9 месяцев назад
Good explanation. Thank u❤
@certifiedbeast5663
@certifiedbeast5663 3 месяца назад
sir can you make a video on this topic really quick i have java exam in 2 days please sir Explain the following operations with examples. (i)> (iii)>>>
@mtbmtbmtbcycle8797
@mtbmtbmtbcycle8797 Год назад
sir your web site is really good how to to build a web site like the one you have? please make a playlist on it i am 1 st year in cse though!
@LearningMonkey
@LearningMonkey Год назад
Yes we are starting full stack web development course from July. Have a great learning
@mtbmtbmtbcycle8797
@mtbmtbmtbcycle8797 Год назад
@@LearningMonkey Thank you Sir 🙂
@navaskhaniv-b8719
@navaskhaniv-b8719 7 месяцев назад
can we do a left shift to negative numbers ? if yes then like how right shift(>>) maintains sign, the same should be applicable to left shit, is that right ? also it is wrong method to teach right shift(>>) because while doing right shift we need to put zero as the right side's first element like how we put zero in left side's first element of left shift. but you mentioned that first bit of right shift's first element should always be what we have as first element. please correct it.
@LearningMonkey
@LearningMonkey 7 месяцев назад
Right shift follows arithmetic right shift. Our explanation is correct. Please once execute the code . Left shif is also correct
@Vishnubhandarge1
@Vishnubhandarge1 Год назад
Brother can I skip java and go with python? I have competed c & c++
@LearningMonkey
@LearningMonkey Год назад
Yes go with python.
Далее
Bitwise Right Shift Operator in Python
11:35
Просмотров 24 тыс.
Genetic Algorithms Explained By Example
11:52
Просмотров 318 тыс.
4.7 Left and Right Shift Operator in Java
3:19
Просмотров 260 тыс.