# Showing two decimal place numbers and adding them properly

**URL:** <https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695>\
**Category:** Questions about Thunkable X\
**Tags:** math\
**Created:** [June 20, 2023, 7:50am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695 "2023-06-20T07:50:43Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 20, 2023, 7:50am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/1 "2023-06-20T07:50:43Z")

</div>

THUNKABLE TEAM,

I am stuck while adding the dollars with two decimal values .The values are not rounded to 2 decimal places and the addition is result just appending the values.It adds the values as strings.

Please note.If there are no decimal values the addition function works fine.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 20, 2023, 9:03am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/2 "2023-06-20T09:03:26Z")

</div>

If your blocks are not working the way you expect them to, post a screenshot of the blocks you are using.

You should also give an example of two values you’ve tried to add and the sun that Thunkable is displaying.

---

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 21, 2023, 8:54am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/3 "2023-06-21T08:54:27Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/2/02bf6424a97c368c09b7e5758bfa9cfbef3f955b.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/4/341262fc229e015fd777f94e0df15774aa28c74d.png)  
When the button ‘plus 1’ and ‘plus 2.5’ are clicked it shows the sum as 12.50

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 21, 2023, 10:06am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/4 "2023-06-21T10:06:26Z")

</div>

That’s strange. That does seem like a possible bug.

Can you post a link to your project?

Also, whenever you use a stored variable, you need to give it a value if it is null. Please try adding a When screen is opened block and inside it, if stored variable add = null then set stored variable to 0.

---

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 22, 2023, 7:27am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/5 "2023-06-22T07:27:11Z")

</div>

[https://x.thunkable.com/copy/e16352861abaad1fbf15a42d31559d9d](https://x.thunkable.com/copy/e16352861abaad1fbf15a42d31559d9d)

---

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 22, 2023, 7:30am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/6 "2023-06-22T07:30:19Z")

</div>

![Screen Shot 2023-06-22 at 5.28.31 pm](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/7/37c09e12fc001497815337237b9c92935a80ad52.png)  
I tried it but it still doesn’t work.

---

<div class="post-metadata">

**Author:** ![ak\_coder](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ak_coder/32/156215_2.png) [@ak\_coder](https://community.thunkable.com/u/ak_coder)\
**Post date:** [June 22, 2023, 8:08am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/7 "2023-06-22T08:08:09Z")

</div>

Hello, i have also faced this similar problem few months ago, when i was making a calculator app, my code was very similar to you.  
I suggest you to use `set stored variable add` instead of `change variable add` block to add 2.50, i think is a bug, when we try to set a variable to a specific decimal place, it automatically ignores the last zeroes  
And one more suggestion, when you use this block: `set variable add to add + 2.50`, it will change your variable and text to 2 decimal places but, then also have to use `+1.001 (or any number that can be rounded of to 1.00 like 1.000003, 1.000342) with 2 decimal places`, because if you click button b, it will change 5.00 to 6, instead of 6.00  
So, i think you got your answer, Try this code  
[https://x.thunkable.com/projectPage/649400d012e8d2ad638752b7](https://x.thunkable.com/projectPage/649400d012e8d2ad638752b7)

 ![Screenshot (1565)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/2/a2e73cf4efb238d67f5ae16f65f2fb15a309493c.png)

---

<div class="post-metadata">

**Author:** ![ak\_coder](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ak_coder/32/156215_2.png) [@ak\_coder](https://community.thunkable.com/u/ak_coder)\
**Post date:** [June 22, 2023, 8:20am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/8 "2023-06-22T08:20:10Z")

</div>

And this issue you say is a javascript bug, the thunkable compiler instead of adding 2.50, it first auto round off 2.50 to 2.5 and then concatenate it with previous sum, see as you click it only adds 2 and 5 to the text and the text becomes longer and longer

---

<div class="post-metadata">

**Author:** ![adyupl](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@adyupl](https://community.thunkable.com/u/adyupl)\
**Post date:** [June 22, 2023, 11:45am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/9 "2023-06-22T11:45:16Z")

</div>

Try this 🙂

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/f/2f5e845a05c9efa3c86246ed0b34f5d7c4a478d2.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 22, 2023, 3:23pm UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/10 "2023-06-22T15:23:38Z")

</div>

I would do this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/2/4250fc5dd3669e3fdd9c2cd42c48d77d08b7da5f.png)

---

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 24, 2023, 5:56am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/11 "2023-06-24T05:56:14Z")

</div>

Thank you sir, it works now, I will be implementing this to my app. Thank you so much.

---

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 24, 2023, 9:06am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/12 "2023-06-24T09:06:25Z")

</div>

I need some help with my canteen app, I can’t show the total on screen two and i don’t know how to integrate the decimal solution. I’ll insert the link to my project, please have a look. Will help me greatly. thank you.

[https://x.thunkable.com/copy/e8dcccf8c6b6782906a9093752a72b0a](https://x.thunkable.com/copy/e8dcccf8c6b6782906a9093752a72b0a)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 24, 2023, 3:43pm UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/13 "2023-06-24T15:43:34Z")

</div>

Thanks for sharing the link. Can you also post a screenshot of which blocks you’re using to display the total?

---

<div class="post-metadata">

**Author:** ![ak\_coder](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ak_coder/32/156215_2.png) [@ak\_coder](https://community.thunkable.com/u/ak_coder)\
**Post date:** [June 25, 2023, 3:02am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/14 "2023-06-25T03:02:27Z")

</div>

@baladitya.harshavard, it was so easy, you have to just this `total with 2 decimal places` block

 ![Screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/0/c035889d1ea897490e5aeed29df1c1e4ebd4cf33.png)  
 ![Screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/e/9e81f425784bf7dbacc59883904f85e2b8018239.png)

Note: Just remember,to show a number with decimal, you have to use this `__ with _ decimal places` block  
Here is your updated app:  
[https://x.thunkable.com/projectPage/6497adb063c8f99206f2a3d9](https://x.thunkable.com/projectPage/6497adb063c8f99206f2a3d9)

---

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 25, 2023, 7:22am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/15 "2023-06-25T07:22:01Z")

</div>

Thank you so much, but i’ve got a new problem. In screen two when you add the items, and when you minus with a random minus button it subtracts the total.

 ![Screen Shot 2023-06-25 at 5.21.27 pm](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/6/e698a6fa47010314e568acb085e5459dabc84af8.png)

---

<div class="post-metadata">

**Author:** ![ak\_coder](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ak_coder/32/156215_2.png) [@ak\_coder](https://community.thunkable.com/u/ak_coder)\
**Post date:** [June 26, 2023, 1:04am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/16 "2023-06-26T01:04:21Z")

</div>

@baladitya.harshavard please explain the issue 🧐 🧐 and send link of new app,  
What do you mean by : _random minus button_ and _subtracts the total_  
But the issue i understand, is that you trying to say that if you click on minus btn of any item with 0 items taken, it does not make the item -1 but still cut the price,  
And from the screenshot, you are trying to say that you 2 burgers of 10$, but the total is 0$, when you click on minus btn of cola 4 times.  
If this is your issue, then the solution is, you have to use conditions, when user click on minus btn, if count is 0, then show a text or alert message intead of calling the sum function and rewriting the total.

If this is not the issue, then please elaborate the problem in more detail and send link.

---

<div class="post-metadata">

**Author:** ![baladitya.harshavard](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@baladitya.harshavard](https://community.thunkable.com/u/baladitya.harshavard)\
**Post date:** [June 26, 2023, 6:11am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/17 "2023-06-26T06:11:59Z")

</div>

I have fixed the problem myself, thank you for your time.

---

<div class="post-metadata">

**Author:** ![ak\_coder](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ak_coder/32/156215_2.png) [@ak\_coder](https://community.thunkable.com/u/ak_coder)\
**Post date:** [June 26, 2023, 7:42am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/18 "2023-06-26T07:42:36Z")

</div>

If you have solved your problem, then please mark this issue as solved. 😀 😀 😀

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [September 24, 2023, 7:43am UTC](https://community.thunkable.com/t/showing-two-decimal-place-numbers-and-adding-them-properly/2474695/19 "2023-09-24T07:43:28Z")

</div>

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