### divide by zero in Java

You might be thinking, divide by zero will throw ArithmeticException. But this is not true for floating point numbers.

Divide by zero throws ArithmeticException only when char or integral value are divided by 0. Below two operation throws exception

10/0

'A'/0

If floating point number is divided by 0, output will be

10.2/0

-10.3/0

Output:

Infinity

-Infinity

Divide by zero throws ArithmeticException only when char or integral value are divided by 0. Below two operation throws exception

10/0

'A'/0

If floating point number is divided by 0, output will be

**Infinity**.10.2/0

-10.3/0

Output:

Infinity

-Infinity

Interesting 👍

ReplyDelete