Why do we need to use shift operators in Java?

>What is the purpose of using shift operators instead of division and multiplication?

Solution

Segmentation and multiplication do not really use displacement operators They are an outdated "optimization" and some like applications

They are bit operations and are fully required for bit level operation in integer values

For example, say I have two bytes that are high and low bits of two byte (16 bit) unsigned values Suppose you need to construct this value At @ L_ 301_ 0 @,

int high = ...;
int low = ...;
int twoByteValue = (high << 8) | low;

You can't do this without the liner operator

Answer your question: you use them, you need to use them! No place

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>