# Why no error on dividing by zero

**URL:** https://discourse.processing.org/t/why-no-error-on-dividing-by-zero/39065
**Category:** Beginners
**Created:** [October 4, 2022, 2:19am UTC](https://discourse.processing.org/t/why-no-error-on-dividing-by-zero/39065 "2022-10-04T02:19:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![prathmesh](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@prathmesh](https://discourse.processing.org/u/prathmesh)
#### Post date: [October 4, 2022, 2:19am UTC](https://discourse.processing.org/t/why-no-error-on-dividing-by-zero/39065/1 "2022-10-04T02:19:33Z")

</div>

Namaste everyone,

Why does “int x = 200/0;”  
gives an error but

int x = 200/20\*0; gives the value as 0.?

Thanks.

---

<div class="post-metadata">

### Author: ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)
#### Post date: [October 4, 2022, 3:54am UTC](https://discourse.processing.org/t/why-no-error-on-dividing-by-zero/39065/2 "2022-10-04T03:54:31Z")

</div>

Because `200/20*0` is `(200/20)*0`, not `200/(20*0)`.

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [October 4, 2022, 4:44am UTC](https://discourse.processing.org/t/why-no-error-on-dividing-by-zero/39065/3 "2022-10-04T04:44:46Z")

</div>

> **[Order of Operations - PEMDAS](https://www.mathsisfun.com/operation-order-pemdas.html)**
>
> Learn how to calculate things in the correct order. Calculate them in the wrong order, and you can get a wrong answer!

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [October 4, 2022, 6:14am UTC](https://discourse.processing.org/t/why-no-error-on-dividing-by-zero/39065/4 "2022-10-04T06:14:56Z")

</div>

Hello @prathmesh,

A search for:

> operator precedence Java

will reveal the answer to your question.

The Oracle Java documentation:  
[https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html)

Parentheses discussed here:

> **[Expressions, Statements, and Blocks (The Java™ Tutorials \>        
         ...](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/expressions.html)**
>
> This beginner Java tutorial describes fundamentals of programming in the Java programming language

> When writing compound expressions, be explicit and indicate with parentheses which operators should be evaluated first. This practice makes code easier to read and to maintain.

`:)`

---

<div class="post-metadata">

### Author: ![prathmesh](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@prathmesh](https://discourse.processing.org/u/prathmesh)
#### Post date: [October 4, 2022, 6:43am UTC](https://discourse.processing.org/t/why-no-error-on-dividing-by-zero/39065/5 "2022-10-04T06:43:01Z")

</div>

Thanks for the links 😃
