Can you help me with math blocks?


I am trying to create a measurement converter, I have seen the tutorial to use the math blocks and I still do not understand

(I do not know what would be the most correct if you use text input or label, according to the tutorial it would be label but I think that I should use text input and leave it empty)

What I would like to achieve is to leave some spaces empty so that you can write the numbers to calculate or if I can not create that, then do a drop-down

Once you put the numbers, click on a button and the app calculate it (I know how to do a button!)

The app would have to make three formulas to give the result, what I do not know is if those three formulas would have to indicate all of them with math blocks or create different text input or labels to be able to indicate what actions have to be performed but putting them in not visible to that do not appear.


A text input makes more sense, since it is associated with input, and would even pop up the device keyboard.
With a label, you still need to have ANOTHER component to enter the value to be converted.


I will try to do it using the text input!

I tried to do it with the text input but I do not know how to use the math block correctly.

The blocks are for example 1 + 1 and what I need is to replace those numbers with those that are entered in the text input.

I think I should put When Button click do and insert the three formulas together, but I do not know how to put is that the third formula is a division of the first and second

Hi there,

You can get the value from a Text Input with the block ‘from Text Input get Text’


You can then put this block in a Math block

You can also nest math blocks in each other. The following is the equivalent of ((1 + 2) / (3 - 4))

Does this help you understand the Math blocks? Let me know if you have any other questions!

1 Like

I’ll try again, give me a few days to do it and I’ll tell you if I’ve understood everything



Thanks for your help, I’ve finally been able to make everything work well!

But I have one last doubt, the result that appears has 16 decimals, I have seen a block called round, I have put it in before the math blocks but it does not work.

Do you know how the round block works?


Can you provide an example please?

Does this mean it’s .0100000000000000?

1 Like

Of course!

For example, the result is 1.273479784 so then will be rounded to 1.3

It would be if the number is equal to or less than 0.4 round down and if it is 0.5 or higher round up.


1 Like

Round returns an integer.
If you have 1.273479784, it will round to 1

If you want to round to 1/10th, then you need to multiply by 10, round, and then divide back by 10.

If you want to round to the closest 100th, you multiply by 100, round and divide by 100.


Hi there,

@CBVG pretty much explained this, but you can look at this Rounding a Number tutorial to see how to round numbers to a given amount of decimal places

I send you a capture of what I have done.

Pressing the “Calcular” button (I’m Spanish, it means Calculate), the text input called “Resultado” shows the result of the two operations that are written in the other text input, that result is the one that I want to round.

Maybe the simplest way to do it would be what @CBVG proposes but I do not know how to put the multiplication, rounding and division.

I have to create a group of new blocks or I should add them to the group of blocks that I already have created and wherei?

Thank you very much for the help you are giving to me

1 Like


The roundToPlaces function is one possible generalization of this function. You call it by specifying the value that needs rounding off (which could also be a variable; it can even be “myvalue” in the example, which would end up replacing myvalue with a rounded off version of itself) and the number of places you want to retain. Put a 2 as “places” and it will round off to the nearest 100th. Put 0, and it will round off to the nearest integer. Put -1, and it will round off to the nearest 10 (i.e. 37.123 would round to 40).

The number of places is internally rounded in the function as well, to avoid the issue of someone putting 2.3 in there, which would mathematically work, but would return completely silly looking results.

1 Like

Thanks! I will try later!

1 Like

I’m sorry, but something has failed.

For what you have explained to me I must indicate a value to be rounded with the function.

I have indicated in the function to return the text input “Resultado” (result) with the rounding, “Resultado” replaces Value in your example and in Places I put 2 but still do nothing.

I think the problem is that in your example some variables are created to replace my text input, but I tried to create variables and I could not.

Maybe that’s why in Functions I see “RoundToPlaces” but not apears “with” and can´t put the two variables of your example.

1 Like

First thing, you do not need to round “2” if you put 2. In fact , you do not need to use 10^, this was there only to allow generalization, where you supply the value and the number of places as input to the function.
If you want to round to the nearest 1/100th, then you can divide by 100 and multiply by 100.

Then, there is a philosophical issue with using Resultado.Text as a variable. It is not a variable, it is a formatted field. Resultado comes with a lot of luggage (font size, background colour, positioning and dimension properties) and each time you are changing anything in this kind of field, you are calling a LOT of behind the scene operations. The idea is that while you are dealing with math, keep it simple and use math variables. AFTER you are finished with the number operation, THEN you are putting the result in Resultado.Text

That said, if those are all your blocks, where is the call to “roundToPlaces”?
It is not going to call itself just because it is defined.

You noticed that I made it use of the arguments, that way it can be used in line. And it returns a value, that means roundToPlaces does not change anything but itself, so it returns a value.

This is how you call it:

In this example, you put whatever equation you used to feed Resultado, the difference is that it has to go through the roundToPlaces as an argument, along with the number of places. Again, if you will always round only to 2, you can make the procedure simpler by multiplying and dividing by 100, and removing the second argument by clicking on the blue gear and dragging it out.

1 Like

Thanks but I still can not use RoundToPlaces as you do, I only see a block with the name but it does not let me define two values as in your example.

I have searched the Thunkable tutorial but I have not found anything that has helped me to understand that Function block.

Could you help me one more time, please?

1 Like

Hi there,

When you click the gear icon in a function block, you will see the option to add and name inputs


Then when you call the function, you’ll be prompted to set values for these inputs


1 Like

Wooow I saw before that option clicking on the gear but I thought it was something different!

I’ve tried again, this time with the simplified option that @CBVG has given.

What I think I have done has been the following:

When you click on the Calcular (Calculate) button, the text input Resultado (Result) will show the result of the formula and the function block returns the result with the round that is the variable Calculado multiplied and divided by 100 to simplify because I want to always round to 2 decimals, and this will should give a result with two decimals … but now the result is always 0!

1 Like

That is because you put the “round” in the wrong place

It has to be

return = ( round (calculo * 100) ) /100

But you put

return = round ( (calculo * 100 ) / 100)

which rounds the result to 0 decimal and has the division/multiplication achieving sweet nothing.