JSF EL Arithmetic Operations - Samples
|
|
|
Arithmetic Operators
Arithmetic is provided to act on integer (BigInteger and Long) and floating point�(BigDecimal and Double) values. There are 5 operators:
- Addition: +
- Substraction: -
- Multiplication: *
- Division: / and div
- Remainder (modulo): % and mod
The last two operators are available in both syntaxes to be consistent with XPath and�ECMAScript.
Arithmetic operations samples
| EL Expression | Result |
|---|---|
| #{10.2 + 20.3} | 30.5 |
| #{-40 - 20} | -60 |
| #{20 * 2} | 40 |
| #{3/4} | 0.75 |
| #{3 div 4} | 0.75 |
| #{10/0} | Infinity |
| #{50%8} | 2 |
| #{50 mod 8} | 2 |
| #{(10==20) ? "true" : "false"} | false |