# Calculating results to two significant figures

**URL:** https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598
**Category:** Questions about Thunkable X
**Created:** [February 24, 2024, 9:13pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598 "2024-02-24T21:13:30Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![catherine.jeanesq](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@catherine.jeanesq](https://community.thunkable.com/u/catherine.jeanesq)
#### Post date: [February 24, 2024, 9:13pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/1 "2024-02-24T21:13:30Z")

</div>

I am trying to get my app to calculate results to significant figures. Does anyone know how to go about doing this?

Thanks!

---

<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: [February 24, 2024, 9:47pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/2 "2024-02-24T21:47:28Z")

</div>

Do you mean like rounding to a certain decimal value? If so, would this block do what you need? [Math - Thunkable Docs](https://docs.thunkable.com/v/snap-to-place/math#round-to-x-decimal-places)

---

<div class="post-metadata">

### Author: ![catherine.jeanesq](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@catherine.jeanesq](https://community.thunkable.com/u/catherine.jeanesq)
#### Post date: [February 24, 2024, 10:17pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/3 "2024-02-24T22:17:36Z")

</div>

Not exactly. With rounding to two decimal places 210.988098 would become 210.99, whereas with two significant figures it would become 210. I don’t know if there is a built in option with Thunkable to do this.

---

<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: [February 25, 2024, 12:35am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/4 "2024-02-25T00:35:10Z")

</div>

No, there isn’t. But I’m guessing there is a javascript function or Google Sheets formula that you can use externally and then get the resulting data into Thunkable.

---

<div class="post-metadata">

### Author: ![Goldking](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/goldking/32/165073_2.png) [@Goldking](https://community.thunkable.com/u/Goldking)
#### Post date: [February 26, 2024, 7:37am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/5 "2024-02-26T07:37:17Z")

</div>

I haven’t tried it but what happen rounding to 3 decimal places and then round the result to 2 decimal places ? Probably the same 🤣

Provide another example of rounding to better understand.

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [February 26, 2024, 9:35am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/6 "2024-02-26T09:35:47Z")

</div>

this works. (the rounding rule is simple though , if the fraction ends in 5 or more, round it up)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/e/9e00790df517168fcf9755741f2f0cb86c76b00a.png)

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

example using 12.344 (rounded to 2 places)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/0/b0974c4f8ab93f93f6d92d25dd02035b16928267.png)

example using 12.345 (rounded to 2 places)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/6/06d9f0a5cd41e6f0f69ad77819263c40ac7dda7f.png)

if you don’t want to show the intermediate field (ie. label17), set the font to white or set the field to invisible.

---

<div class="post-metadata">

### Author: ![Goldking](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/goldking/32/165073_2.png) [@Goldking](https://community.thunkable.com/u/Goldking)
#### Post date: [February 26, 2024, 3:11pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/7 "2024-02-26T15:11:09Z")

</div>

I was thinking also about to combine together round with decimal and round up/down or to write a code to fit your round rules

---

<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: [February 26, 2024, 3:50pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/8 "2024-02-26T15:50:02Z")

</div>

I had to Google it but [significant figures](https://www.khanacademy.org/math/arithmetic-home/arith-review-decimals/arithmetic-significant-figures-tutorial/v/significant-figures#:~:text=Significant%20figures%20are%20the%20number,for%20an%20assortment%20of%20numbers.) are very different from rounding.

---

<div class="post-metadata">

### Author: ![Goldking](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/goldking/32/165073_2.png) [@Goldking](https://community.thunkable.com/u/Goldking)
#### Post date: [February 26, 2024, 6:00pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/9 "2024-02-26T18:00:06Z")

</div>

Wow I never meet this kind of rules.

So If I understand well the rules, the two significant figures in this example (only because we don’t know the operation that generated this number ) are 21 (? I’m not sure) so we have to look at the extra number (the first after the last significant figures) and it is a zero ( \< 5) so the number doesn’t change 21 .  
Result 210

- If the extra number is bigger than 5 you have to add +1
- If the extra number is a 5 :  
•If the next number is bigger than zero then add+1  
•If the next numbers are only zero we have to look at  
the number before the extra number  
+ if even not change  
+ if odd then add +1

🤦🏻‍♂️

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [February 26, 2024, 11:25pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/10 "2024-02-26T23:25:05Z")

</div>

i stand corrected. significant digits are different from rounding.

i’ve written a function to return significant\_digits and a demo program to call it.

here are some sample screen shots  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/e/eed65040edc4c8c7613be3ff850c4b05951103d1.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/5/1500c67a988c35ca7ad27d9f26a1879205789d3e.png)

if the input is negative (it has to save the sign, do its thing on the absolute value then re-sign it)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/e/2e645d621d13db4b49b756659d2c9a0b18403c3b.png)

the code blocks are pictured here

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/d/8d9d538b7ebe8d70114f3b3ef96a7dd03d83d11e.png)

here’s the link to the program (please use SCREEN 16)  
[https://x.thunkable.com/copy/dfdc3b1fab18674b3abccf8146152a24](https://x.thunkable.com/copy/dfdc3b1fab18674b3abccf8146152a24)

disclaimer: i’m not using the esoteric rules of rounding - i’m using the rule - round up if digit is 5 or more

---

<div class="post-metadata">

### Author: ![catherine.jeanesq](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@catherine.jeanesq](https://community.thunkable.com/u/catherine.jeanesq)
#### Post date: [March 14, 2024, 1:36am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/11 "2024-03-14T01:36:55Z")

</div>

Thank you so much for all your help with this! It seems to be working really well!

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [March 14, 2024, 8:08am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/12 "2024-03-14T08:08:14Z")

</div>

are you referriing to my suggestion? if you think it answers your question, please mark this thread Solved. thank you.

---

<div class="post-metadata">

### Author: ![catherine.jeanesq](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@catherine.jeanesq](https://community.thunkable.com/u/catherine.jeanesq)
#### Post date: [March 15, 2024, 2:59am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/13 "2024-03-15T02:59:29Z")

</div>

Hi, I’m having some trouble with the code if the number is \<1. Do you mind having a look? Thanks

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [March 15, 2024, 4:28pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/14 "2024-03-15T16:28:52Z")

</div>

what’s wrong? can you provide the input, the actual output from the program and your expected output?

---

<div class="post-metadata">

### Author: ![catherine.jeanesq](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@catherine.jeanesq](https://community.thunkable.com/u/catherine.jeanesq)
#### Post date: [March 16, 2024, 11:50am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/15 "2024-03-16T11:50:48Z")

</div>

It just replies NaN, then when I calculate the number myself, it only seems to do this when the result is \<1. Could I add an if statement into the function so if the number is \<1 I can do round to 2 decimal places? Would that work?

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [March 17, 2024, 12:08am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/16 "2024-03-17T00:08:55Z")

</div>

sorry about that - it couldn’t handle when number is 1 followed by any number of zeroes. my bad.  
here’s the new code. the routine now has an IF block to test for that condition.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/8/f81d07b526a9a7b7990e710d5362133dd3fb5252.png)

here’s a picture of the whole program

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/a/ba6f4812d5b04da9d55c3a184dbea438147ecfc5.png)

and here’s the link (see screen 16)  
[https://x.thunkable.com/copy/c899b3f88ad6558816b8512bacaca324](https://x.thunkable.com/copy/c899b3f88ad6558816b8512bacaca324)

---

<div class="post-metadata">

### Author: ![catherine.jeanesq](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@catherine.jeanesq](https://community.thunkable.com/u/catherine.jeanesq)
#### Post date: [March 17, 2024, 10:06pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/17 "2024-03-17T22:06:53Z")

</div>

I’m still having issues with when the number is \<=0.99. Any numbers above this work perfectly, but not anything less than 1. Do you mind taking a look? Thanks!

 ![NaN blocks](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/1/41a9acfb46f7410d4be294274b448aab8c6ec4df.jpeg)  
 ![NaN blocks_design](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/8/28dbd35396757f14acbb215c47cfecd52f17e4a3.jpeg)

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [March 18, 2024, 1:13am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/18 "2024-03-18T01:13:36Z")

</div>

i took th weights (4,2.7,1.6) from below  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/4/84d0de598bc9ad10b8299f25266c6e39aed66a44.png)

and plugged them into your first 3 formulas  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/6/866edaf0d9d20dd4654715f6e88974dfdd8f0c3d.png)

into this debugging block

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

(which has the same formulas as your first 3 computations).

and i got this result  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/6/b63812c3d981b63a5fa9991152a4c01f7fda05f0.png)

please recheck if you applied my fix the same way , also check if your factors (numerator,denominator) are correct - the formulas don’t seem to agree with the display (esp. mg/kg).

i suggest you make ANOTHER routine with 4 parameters: #of+digits, weight, w\_mult, w\_divsr and return a formula that uses sigdig.

can you display you version of sigdig?

---

<div class="post-metadata">

### Author: ![catherine.jeanesq](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@catherine.jeanesq](https://community.thunkable.com/u/catherine.jeanesq)
#### Post date: [March 18, 2024, 10:36pm UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/19 "2024-03-18T22:36:28Z")

</div>

Hi, here’s my version of sigdig:

 ![sig dig block](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/2/82f517492a40e97b92e9837f59e0cdbd329875b6.jpeg)

---

<div class="post-metadata">

### Author: ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)
#### Post date: [March 19, 2024, 12:57am UTC](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598/20 "2024-03-19T00:57:35Z")

</div>

can you temporarily change your button block (save the old contents) and make it look like the one i made above. and give me the results.

can you give me the actual values you are trying that are giving you problems?

[Next page](https://community.thunkable.com/t/calculating-results-to-two-significant-figures/2854598.md?page=2)
