# Converting inputs into int types

**URL:** <https://discourse.processing.org/t/converting-inputs-into-int-types/22276>\
**Category:** Coding Questions\
**Created:** [June 30, 2020, 6:57am UTC](https://discourse.processing.org/t/converting-inputs-into-int-types/22276 "2020-06-30T06:57:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![olorin](https://avatars.discourse-cdn.com/v4/letter/o/f17d59/32.png) [@olorin](https://discourse.processing.org/u/olorin)\
**Post date:** [June 30, 2020, 6:57am UTC](https://discourse.processing.org/t/converting-inputs-into-int-types/22276/1 "2020-06-30T06:57:14Z")

</div>

I’m trying to take in user number inputs, convert them into int types, multiply, convert the outcome back into a string, and print this out. I keep getting the Not a Number result when ever i try int(input.value()). does anyone know how to do this properly?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 30, 2020, 7:13am UTC](https://discourse.processing.org/t/converting-inputs-into-int-types/22276/2 "2020-06-30T07:13:17Z")

</div>

Please see previous post, this has been asked before [Covert String to Integer](https://discourse.processing.org/t/covert-string-to-integer/2430)

---

<div class="post-metadata">

**Author:** ![olorin](https://avatars.discourse-cdn.com/v4/letter/o/f17d59/32.png) [@olorin](https://discourse.processing.org/u/olorin)\
**Post date:** [June 30, 2020, 4:20pm UTC](https://discourse.processing.org/t/converting-inputs-into-int-types/22276/3 "2020-06-30T16:20:17Z")

</div>

this post is not the same question. I’m trying to convert an input.value() into an integer in p5.js not processing. When I use the normal string to integer method I get NaN.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 30, 2020, 4:46pm UTC](https://discourse.processing.org/t/converting-inputs-into-int-types/22276/4 "2020-06-30T16:46:27Z")

</div>

Woops so it is, have you tried an if statement before arising the string. It might be that some conditions return a blank string without a number

Ie if(input.value()!="")

---

<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:** [July 1, 2020, 11:13am UTC](https://discourse.processing.org/t/converting-inputs-into-int-types/22276/5 "2020-07-01T11:13:14Z")

</div>

> [@olorin](#):
>
> When I use the normal string to integer method I get `NaN`.

Are you specifying an input of type “number”? 🤔  
`input = createInput('0', 'number');`

> **[reference | p5.js](https://p5js.org/reference/#/p5/createInput)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

> **[\- HTML: HyperText Markup Language | MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number)**
>
> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.
