Limit of Math Is even function

Hi all
Please my observation below when I wanted to test an even number. Is there a limit on the numbers Thunkable can handle.
image

even2

You’re testing whether or not a text string is even.

You need to convert the text to a number first. The way to do that is to add zero to the text input’s text.

image.png
image.png

Hi Tatiang, Thanks for helping. I changed the settings as above, are they correct? It still gives the same.

No. Those are the exact same blocks.

You need to get the addition (+) block from the Math drawer and add zero (0) to Text_Input3’s Text.

This is a slightly older project but a similar idea:

image

Another way to do this is to multiply by 1, as shown here: How to check if text input is a number? - #3 by domhnallohanlon

Actually forgot to tell you that it works properly for smaller numbers even if we don’t convert it to a number. I did the changes and it shows the output below. I am sceptical that it has some limit on the range of numbers it can check, What is your opinion?image.pngimage.png
image.png

@cc_mindchamp I would guess you’re right, but it would be a max imposed by JavaScript in this case vs anything specifically related to Thunkable.

I did a search on “what is the largest number in javascript” and that comes back as: 9007199254740991

Testing proves this to be true.

math-limit-00
math-limit-01
math-limit-02
math-limit-03

However, validating user input is always best practice, and I would agree with @tatiang 's recommendation to multiply by 1 to ensure you’re dealing with a number.

JavaScript can sometimes misinterpret the operation because + is used for addition and concatenation (joining strings together). Here is a test I ran in the browser console that proves the point:

1 Like

Thank you both of you @marion.dorsett @tatiang

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.