<%@ page import="java.util.*" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/ea/core" %> JSTL: EcmaScript EL Support -- Bitwise Operator Example

Bitwise Operators

The Bitwise operators perform boolean algebra on the individual bits of the operands or shift bits left and right. It is used to manipulate the binary numbers and binary representation of decimal integers. The operators return Nan if the operands are not integers or are too large to fit in a 32-bit integer representation.

Here are some examples:

<% request.setAttribute("a", new Integer(13)); %> <% request.setAttribute("b", new Integer(1)); %> <% request.setAttribute("c", new Integer(0)); %>

Operator: & (Bitwise And)

Operation Result
&

Operator: | (Bitwise Or)

Operation Result
|

Operator: ^ (Bitwise Xor)

Operation Result
^

Operator: ~ (Bitwise Not)

Operation Result
~

Operator: << (Shift Left)

Operation Result
<<

Operator: >> (Shift Right with Sign)

Operation Result
>>

Operator: >>> (Shift Right Zero Fill)

Operation Result
>>>