Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP C/HP-UX Reference Manual: Workstations and Servers > Chapter 5 Expressions

Bitwise Shift Operators

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

The bitwise shift operators shift the left operand left (<<) or right (>>) by the number of bit positions specified by the right operand.

Syntax

  shift-expression ::=
additive-expression
shift-expression << additive-expression
shift-expression >> additive-expression

Description

Both operands must be of integral type. The integral promotions are performed on both operands. The type of the result is the type of the promoted left operand.

The left shift operator << shifts the first operand to the left and zero fills the result on the right. The right shift operator >> shifts the first operand to the right. If the type of the left operand is an unsigned type, the >> operator zero fills the result on the left. If the type of the left operand is a signed type, copies of the sign bit are shifted into the left bits of the result (sometimes called sign extend).

Example

var1>>var2
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.