- Arithmetic operators are used to perform fundamental arithmetic operations like addition,subtraction,etc.
- There are 5 arithmetic operators in java and these operators act an two operands at a time,hence these are called as “Binary Operators.“
When ever we are applying any arithmetic Operator on two operands a and bthe result type is
max(int,type of a,type of b)
- double+float=double max(int,double,float)
- short+byte=int max(int,short,byte)
In the integral arithmetic,there is no way to represent Infinity hence “division/0” is always ” ArithmeticException” in integral arithmetic.
But in the case of floating point arithmetic there is a way to represent Infinity
Float and Double classes contains the following constants.
Hence division by zero is not “ArithmeticException” in floating point arithmetic.
System.out.println(10.0/0); //infinity System.out.println(10/0.); //infinity System.out.println(-10.0/0);//-infinity