The Java language provides 7 operators that perform arithmetic on integer and floating point values.
\\+
operators:\\+
operator that performs string concatenation. That is described in a separate example.)\\-
operators:The operators require numeric operands and produce numeric results. The operand types can be any primitive numeric type (i.e. byte
, short
, char
, int
, long
, float
or double
) or any numeric wrapper type define in java.lang
; i.e. (Byte
, Character
, Short
, Integer
, Long
, Float
or Double
.
The result type is determined base on the types of the operand or operands, as follows:
double
or Double
, then the result type is double
.float
or Float
, then the result type is float
.long
or Long
, then the result type is long
.int
. This covers byte
, short
and char
operands as well as `int.The result type of the operation determines how the arithmetic operation is performed, and how the operands are handled
double
, the operands are promoted to double
, and the operation is performed using 64-bit (double precision binary) IEE 754 floating point arithmetic.