# The issue about adding two values of decimal members?

**URL:** https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452
**Category:** Questions about Thunkable X
**Tags:** solved, beginner, help
**Created:** [February 12, 2022, 1:17pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452 "2022-02-12T13:17:38Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![aaronbx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aaronbx/32/124683_2.png) [@aaronbx](https://community.thunkable.com/u/aaronbx)
#### Post date: [February 12, 2022, 1:17pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/1 "2022-02-12T13:17:38Z")

</div>

I find bugs 1.7 + 1.4 = 3.0999999999999996!  
 ![錄製_2022_02_12_21_15_51_867](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/a/aaf1285f81e3a5e7a0b46e4f304081e7f7dba21d.gif)

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [February 12, 2022, 1:25pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/2 "2022-02-12T13:25:58Z")

</div>

It’s called floating point arithmetic. It’s weird. See more [here](https://community.thunkable.com/t/0-1-0-1-0-010000000000002-error/1243946/11)

And [here](http://www.smbc-comics.com/?id=2999)

---

<div class="post-metadata">

### Author: ![aaronbx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aaronbx/32/124683_2.png) [@aaronbx](https://community.thunkable.com/u/aaronbx)
#### Post date: [February 12, 2022, 1:31pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/3 "2022-02-12T13:31:11Z")

</div>

I can not understand!  
How to calculate more accuracy?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [February 12, 2022, 7:34pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/4 "2022-02-12T19:34:00Z")

</div>

> [@aaronbx](#):
>
> How to calculate more accuracy?

Fix the number of decimal places, say 3 or 5 to get a more readable result.

---

<div class="post-metadata">

### Author: ![aaronbx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aaronbx/32/124683_2.png) [@aaronbx](https://community.thunkable.com/u/aaronbx)
#### Post date: [February 13, 2022, 3:42pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/5 "2022-02-13T15:42:10Z")

</div>

![unknown 1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/6/561c8fa5157f6beeb55d51dcb80e6e4f75e5da2c.png)  
But it crash the app variable can’t put this block!

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [February 13, 2022, 7:58pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/6 "2022-02-13T19:58:36Z")

</div>

> [@aaronbx](#):
>
> But it crash the app

Why are you using `length of` block for the decimal place numbers?  
Use a simple number such as **4**.

---

<div class="post-metadata">

### Author: ![aaronbx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aaronbx/32/124683_2.png) [@aaronbx](https://community.thunkable.com/u/aaronbx)
#### Post date: [February 13, 2022, 8:31pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/7 "2022-02-13T20:31:12Z")

</div>

It is because according to the number of the decimal point

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [February 13, 2022, 8:40pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/8 "2022-02-13T20:40:41Z")

</div>

> [@aaronbx](#):
>
> according to the number of the decimal point

Can you place a simple number instead of this `length of` block and see the outcome?

First see it working then try to enhance it.

When I use this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/c/2c824180497a2ac003c2c3e44b0595f729446e09.png)

I get this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/c/7c48ed88332ec396559e729c8c512ce3a196779b.png)

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [February 14, 2022, 2:11pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/9 "2022-02-14T14:11:34Z")

</div>

What is ‘floating’? That red ‘length’ block wants a string, and it might be crashing if you’re not feeding it a string.

If you’re trying to put in the actual value of the math (is floating = 3.9999999999996?), that won’t fix your floating point error. You need to round your answer to some reasonable number of display digits (and it could be something large, like 10 decimal places), not tell it to round to the digits it actually thinks it has, or else you won’t mask the floating point error.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [February 14, 2022, 2:34pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/10 "2022-02-14T14:34:56Z")

</div>

Welcome back Dr. Sarisky. @catsarisky

---

<div class="post-metadata">

### Author: ![aaronbx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aaronbx/32/124683_2.png) [@aaronbx](https://community.thunkable.com/u/aaronbx)
#### Post date: [February 14, 2022, 4:23pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/11 "2022-02-14T16:23:10Z")

</div>

with 5 decimal places. mine is ok  
I think it is like this  
For example: floating variable  
0.1 + 0.11 → 1 \< 2  
than floating variable 2 → 0.21 (Correct to Two Decimal Places)  
0.0001 +0.01 4 \> 2  
than floating variable 4 → 0.0101 (Correct to Four Decimal Places)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [February 14, 2022, 5:00pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/12 "2022-02-14T17:00:47Z")

</div>

I set my example to 10 decimal places and then multiplied the result by **1** to get rid of extra zeros.

See this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/7/c7b61b424f3a6b4514b01ce7a8c1efc92da9eb4b.png)

Result  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/7/17a166400cedce49693c323795aa5054ed84dbfc.png)

Hope this makes it clear.

---

<div class="post-metadata">

### Author: ![aaronbx](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/aaronbx/32/124683_2.png) [@aaronbx](https://community.thunkable.com/u/aaronbx)
#### Post date: [February 14, 2022, 6:20pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/13 "2022-02-14T18:20:52Z")

</div>

Great, that is the final answer! appreciated!  
must the answer multiply by one to get right!

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [February 14, 2022, 6:54pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/14 "2022-02-14T18:54:15Z")

</div>

> [@aaronbx](#):
>
> must the answer multiply by one to get right!

This is just a trick to get rid of the extra **000** in the answer. You can do that same if you add **ZERO** to the answer.

In case you want the **000** to show then just remove the last step.

---

<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: [May 15, 2022, 6:55pm UTC](https://community.thunkable.com/t/the-issue-about-adding-two-values-of-decimal-members/1730452/15 "2022-05-15T18:55:02Z")

</div>

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