Javascript bitwise left shift operator (<)

Source: Internet
Author: User

Javascript bitwise left shift operator (<)

This article mainly introduces the Javascript bitwise left shift operator (<) to convert the expression number to binary, and then to the bitwise information of the expression to the Left shift. For more information, see

Bitwise left shift operator (<)

Left shift expression bit.

 

Result = expression1 <expression2

 

Parameters

Result

 

Any variable.

 

Expression1

 

Any expression.

 

Expression2

 

Any expression.

 

Description

<Operator shifts all the bits of expression1 to the specified bits of expression2 to the left. For example:

 

Var temp

Temp = 14 <2

The value of the temp variable is 56, because 14 (that is, 00001110 of the binary) shifts to the left two places equal to 56 (that is, 00111000 of the binary ).

 

The bitwise left shift operator (<) in Javascript converts the expression number to a binary value, and then shifts the bitwise of the expression to the left.

 

Result = [number to be displaced] <[number of digits to be displaced]

 

The bitwise left shift operator (<) shifts the bit of the number to be shifted to the specified number of shifted digits. For example:

 

The Code is as follows:

Var temp;

Temp = 14 <2;

/*

The binary value of 14 is 00111000.

00001110 left displacement 2-digit 00111000 = 56

*/

Alert (temp );

// [56] is displayed]

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.