 # Trying to add number from Text Input

The thing that interests me most is to know why the sum of the label “LaTotal” gives me NaN, and why when you open the screen instead of the number the word total appears, but I would also like to know why what worked a few months ago (second image) now no longer works.

I have already written a post for these blocks.

NaN - not a number. This means that you are not trying to add numbers, but strings. If you add 1 + 1, it will be 2, and if “1” + 1 or " 1 " + “1”, it will be NaN. How do I add “1” + “1”? To do this, you need to convert a number in string form to a number, for example, using the addition block with 0. 5 Likes

That’s interesting,
what does 2e2 convert to? Exponential? 2 * 2? “e” performs the operation of multiplying a number by 1 with the specified number of zeros.

2e2 = 2 * 100 or analog 3e5 = 3 * 100000

1e-2 = 1/100 = 0.01

If you are interested, try this too 1 Like

Check if that two statements are numbers, if not it will give NaN. Both LaTotal and LaPartial must be numbers, otherwise it will give NaN.

BTW, this happened to me again. I used the way @actech suggested but still not working. I was trying to add scores, but it gives me NaN as a result of the score.

Edit i modified it but per it gives me 201 rather than 1

Can you show me a project or blocks where my method doesn’t work? I don’t want to sound too cool, but my method should work well if the system is updated, there are no bugs, and the method is used correctly.

1 Like

it now works but weird as it sometimes work and sometimes dont

If this is the case, then you have an accidental error - this is a very unpleasant error that must be fixed. Imagine that your car’s brakes are working and not working. I would never drive a car like this.

agree, contact thunkable support but i don’t know where

I can’t do this because I don’t see a problem. I can only see the problem if I run the project and see it on the screen of my device. Can you give a simple example of what doesn’t work?

1 Like

@iaia are the text_inputs given a starting value somewhere or is there a chance that their initial value is “undefined”?

What blocks are you using @zbk0612eip8w?

Thanks

im using a score for that block in the quiz app remix

FIXED
the problem was in a ghost entry in the database that I didn’t know how to delete
(right click on it → remove row) that affected the operations

I’m having a similar issue with the sum of list it gives a string sum and not a numerical one, the starting value of the label is zero (number), then it’s added one by one with every click, multiplied with database stored variable, the result is stored in the database and the list is the result of those. It used to work but now it does not.
I’ve tried @actech’s +0 and it does work, but since i use only positive numbers I use the command “absolute” which takes the value of the number without the positive or negative otherwise it won’t work

if you can’t get a sum of list as you expect, it’s because the list is alphabetic (non numeric), try this for summing instead
https://x.thunkable.com/copy/b73c40571d5d6dd41b7580f752399b1d

1 Like

Thx, good to know, but I fortunately already solved my problem.

1 Like

I just found out this

1 Like