# Unable to generate proper float value in Processing

**URL:** <https://discourse.processing.org/t/unable-to-generate-proper-float-value-in-processing/29352>\
**Category:** Beginners\
**Created:** [April 13, 2021, 11:55pm UTC](https://discourse.processing.org/t/unable-to-generate-proper-float-value-in-processing/29352 "2021-04-13T23:55:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![estevancarlos](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/estevancarlos/32/12819_2.png) [@estevancarlos](https://discourse.processing.org/u/estevancarlos)\
**Post date:** [April 13, 2021, 11:55pm UTC](https://discourse.processing.org/t/unable-to-generate-proper-float-value-in-processing/29352/1 "2021-04-13T23:55:08Z")

</div>

I am converting p5js to Processing. I’ve actually used Processing for years but I specialize in Javascript. I am surprised at this issue because I’ve never noticed before. Not sure how I overlooked it.

When calculating a float value in **P5js** I get this expected result:

`let k = kMax * sqrt(i/n);`

> 0.653496871297773

When calculating a float value in **Processing** I get this _unexpected_ result:  
`float k = kMax * sqrt(i/n);`

> 0.0

**What do I need to do in order to generate a proper float value in Processing?**

---

<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:** [April 14, 2021, 12:04am UTC](https://discourse.processing.org/t/unable-to-generate-proper-float-value-in-processing/29352/2 "2021-04-14T00:04:00Z")

</div>

At least 1 of the variables _i_ or _n_ needs to be of datatype `float` for the operator `/` to evaluate its operands as a `float` value. 🧐

Alternatively you can temporarily upcast 1 of the variables to `float`:  
`float k = kMax * sqrt( (float) i / n );`

---

<div class="post-metadata">

**Author:** ![estevancarlos](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/estevancarlos/32/12819_2.png) [@estevancarlos](https://discourse.processing.org/u/estevancarlos)\
**Post date:** [April 14, 2021, 12:14am UTC](https://discourse.processing.org/t/unable-to-generate-proper-float-value-in-processing/29352/3 "2021-04-14T00:14:18Z")

</div>

That was it. I overlooked the fact that one of my variables didn’t have a proper datatype. Glad the solution makes sense. Wasn’t sure if I was misunderstanding something. Thanks.
