[Bug] Typecasting doesn't work when trying to add

My goal is to create a simple calculator by setting two user input boxes into variables, and using those variables to add/subtract/multiply/divide each other, saving it in a final result variable.

Thunkable iOS correctly calculates two values when it is subtracted, multiplied, or divided. However the addition function believes the variables are a String instead of an Int.

I tested the same function with numerical values and it calculates properly. I am not sure if the bug is with the typecasting or addition.

Any help would be appreciated.


So what’s happening? Does it concatenate the strings? i.e if your try 1+ 2 do you get “12” instead of 3?

Yes exactly, but 1-2, 1*2, and 1/2 are all working correctly.

Hi @Teacher_Mah, I don’t have access to my iPhone at the moment, but you could try something like this?

My idea is that passing your number variables through some other Math blocks will imply that the compiler should treat them as numbers rather strings.

Thanks for pointing this out though, hopefully there will be a “numbers only” option added to the TextInput in the future.


Thanks! This is a good workaround :slight_smile:

Did you test it? Does it work??

Yes it does - the calculation works. I thought I tried the round option earlier but regardless, “round” will force the variable as a number.

1 Like

Try this new feature::

Changing the input fields to ‘numeric’, and leaving the code without the rounding does not work, and continues to join the numbers as text (1 + 2 = 12).

However, the original solution using “round” does work.