# Mple division does not output a float number

**URL:** https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105
**Category:** Processing.py
**Created:** [September 29, 2024, 5:51pm UTC](https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105 "2024-09-29T17:51:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![blindschleiche](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@blindschleiche](https://discourse.processing.org/u/blindschleiche)
#### Post date: [September 29, 2024, 5:51pm UTC](https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105/1 "2024-09-29T17:51:20Z")

</div>

i am testing python with processing. one of my first scripts was a simple division 13 divided by 2 which should give out the result 6.5 - but in the console there is 6  
does anybody know why it seems to be impossible to give out a float number? by default the pure python gives out a float, if it is a division - processing.py doesn’t  
thanks for a hinch

---

<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: [September 29, 2024, 6:06pm UTC](https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105/2 "2024-09-29T18:06:48Z")

</div>

Take a look here:

_[Troubleshooting · processing/processing Wiki · GitHub](https://github.com/processing/processing/wiki/Troubleshooting#why-does-2--5--0-instead-of-04)_  
Why does 2 / 5 = 0 instead of 0.4?

This may apply to Processing Python as well.

`:)`

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 29, 2024, 6:56pm UTC](https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105/3 "2024-09-29T18:56:21Z")

</div>

As @glv has already pointed out, division in Jython and in Python 2 is the same as in Java:  
If both operands are of integer type, the division’s result got its fractional part removed (truncates).

Workaround is also very similar:  
Make sure 1 of the operands is of float type, by adding a decimal point for literals, or using **float()** to convert a variable.

---

<div class="post-metadata">

### Author: ![blindschleiche](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@blindschleiche](https://discourse.processing.org/u/blindschleiche)
#### Post date: [September 30, 2024, 11:26am UTC](https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105/4 "2024-09-30T11:26:24Z")

</div>

thank you for the hint. it seems, that it is nessesary to write 13.0 / 2 - then it works.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 30, 2024, 12:14pm UTC](https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105/5 "2024-09-30T12:14:48Z")

</div>

We can even just add the dot w/o the zero: `13. / 2` or `13 / 2.` 😉  
Or in this case, multiply by half: `13 * .5` 🧙

---

<div class="post-metadata">

### Author: ![blindschleiche](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@blindschleiche](https://discourse.processing.org/u/blindschleiche)
#### Post date: [September 30, 2024, 2:06pm UTC](https://discourse.processing.org/t/mple-division-does-not-output-a-float-number/45105/6 "2024-09-30T14:06:08Z")

</div>

cool - i just tested it - works perfect 👍
