Arithmetic Operator in JSP

What are the JSP Expression Language Arithmetic Operator?

Explanation

Arithmetic operators are used for basic arithmetic operations like addition, subtraction, multiplication , division and modulus in JSP Expression Language.
Logic Expression Result
Addition ${2+3} 5
Addition ${2.5+3} 5.5
Addition ${3.3E4 + 2.5} 33002.5
Subraction ${-2-3} -5
Multiplication ${2*3} 6
Division ${6/2} 3
Division ${6 div 2} 3
Division ${6/0} Infinity
Modulus ${7%3} 1
Modulus ${7 mod 3} 1

Example :


The Modulus of 7 and 3 is: "${7%3}"
Result :

The Modulus of 7 and 3 is: "1"

In the above example we have used the "%" or the "modulus" operator to find the remainder of x and y, which has values "7" and "3". The result is 1 as the remainder after dividing "7" by "3" is 1.

Ask Questions

Ask Question