Bit Shift Calculator

A bit shift slides the binary digits of a number left or right by a set number of places, and this calculator shows every common variant at once. Enter a whole number and how many bits to shift by, and you get the left shift, the signed right shift and the unsigned right shift, each in both decimal and binary. Shifting is one of the fastest operations a processor can do and it turns up constantly in low-level code: a left shift by one doubles a value, a right shift by one halves it, and shifts are used to pack several small fields into one word, to build bit masks, and to read or write individual flags. The left shift moves bits toward the high end and pads the low end with zeros, so each place shifted multiplies by two. The signed right shift moves bits toward the low end while copying the sign bit down, which keeps negative numbers negative. The unsigned right shift also moves bits down but always feeds in zeros from the top, treating the number as an unsigned 32-bit value, so it differs from the signed version only when the input is negative. Following the convention used by JavaScript and most C-style languages, the calculator works in 32-bit signed integers and takes the shift amount modulo 32. Enter your value and shift count and the results update immediately.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
240
left shift result (value shifted left, in decimal)
Value in binary00111100
Left shift, binary11110000
Signed right shift >>15
Unsigned right >>>15

Results use 32-bit signed integer arithmetic; the shift amount is taken modulo 32 and bits shifted past the ends are discarded.

How it works

Your value is first converted to a 32-bit signed integer, and the shift count is reduced modulo 32. The left shift (<<) moves every bit that many places toward the high end and fills the new low bits with zeros, which multiplies the value by two for each place, up to the point where high bits fall off the top of the word. The signed right shift (>>) moves bits toward the low end and copies the existing sign bit into the vacated high bits, so a negative number stays negative and the result is roughly the value divided by two per place, rounding toward negative infinity. The unsigned right shift (>>>) moves bits the same way but always fills the high bits with zeros, reading the pattern as an unsigned number. Binary results are padded so the bit pattern lines up.

Worked example

Take the value 60, which is 00111100 in binary, and shift by 2 bits. Shifting left by 2 moves the pattern to 11110000, which is 240 in decimal, the same as multiplying 60 by four. Shifting right by 2 gives 00001111, which is 15, the same as dividing by four and rounding down. Because 60 is positive, the unsigned right shift gives the same answer, 15. These match the defaults shown in the calculator above.

Related calculators