# Calculation result doesnt make sense

**URL:** <https://discourse.processing.org/t/calculation-result-doesnt-make-sense/29232>\
**Category:** Beginners\
**Created:** [April 8, 2021, 10:16pm UTC](https://discourse.processing.org/t/calculation-result-doesnt-make-sense/29232 "2021-04-08T22:16:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rektic](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@Rektic](https://discourse.processing.org/u/Rektic)\
**Post date:** [April 8, 2021, 10:16pm UTC](https://discourse.processing.org/t/calculation-result-doesnt-make-sense/29232/1 "2021-04-08T22:16:50Z")

</div>

Hi, I need help. Its simple, 3\*1/4 obviously equals 0.75 but when I write the following code, it says, the result is 0.0

float x = 3\*1/4;

void draw(){  
println(x);  
}

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 8, 2021, 10:41pm UTC](https://discourse.processing.org/t/calculation-result-doesnt-make-sense/29232/2 "2021-04-08T22:41:53Z")

</div>

Hi! Welcome to the forum!

It’s one of the strange things of coding. When you write 3, it’s integer. 3 \* 1 is 3 and 3 / 4 is 0 because they are integers. Finally, 0 is converted to float 0.0 and assigned to the variable.

When you write 3.0, it’s float. 3.0 / 4.0 is 0.75.

🤯

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 8, 2021, 11:18pm UTC](https://discourse.processing.org/t/calculation-result-doesnt-make-sense/29232/3 "2021-04-08T23:18:05Z")

</div>

or like this

```auto
float x = float(3)*1/4;

void draw() {
  println(x);
  noLoop();
}

```

---

<div class="post-metadata">

**Author:** ![Rektic](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@Rektic](https://discourse.processing.org/u/Rektic)\
**Post date:** [April 9, 2021, 8:42am UTC](https://discourse.processing.org/t/calculation-result-doesnt-make-sense/29232/4 "2021-04-09T08:42:57Z")

</div>

Thanks guys, it works now
