# Rounding decimals

**URL:** <https://cl.desmos.com/t/rounding-decimals/1227>\
**Category:** Questions\
**Created:** [July 16, 2020, 6:55pm UTC](https://cl.desmos.com/t/rounding-decimals/1227 "2020-07-16T18:55:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micah\_Baldree](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/micah_baldree/32/387_2.png) [@Micah\_Baldree](https://cl.desmos.com/u/Micah_Baldree)\
**Post date:** [July 16, 2020, 6:55pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/1 "2020-07-16T18:55:20Z")

</div>

I have used this code in the past when comparing input answers to what I want:

```auto
\\operatorname{round}\\left(${expectedValue},2\\right)

```

and that works, but when it comes to showing a rounded decimal in the content doesnt round. What can I use to round a calculated number and then show it in the displayed content?

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 16, 2020, 7:38pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/2 "2020-07-16T19:38:27Z")

</div>

Make a variable with that code, and display that should work. The only time I don’t think it works is if there’s a trailing zero.

---

<div class="post-metadata">

**Author:** ![Micah\_Baldree](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/micah_baldree/32/387_2.png) [@Micah\_Baldree](https://cl.desmos.com/u/Micah_Baldree)\
**Post date:** [July 16, 2020, 7:42pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/3 "2020-07-16T19:42:08Z")

</div>

```auto
t=results.script.total
tp=results.script.totalpercent
tpr="\\operatorname{round}\\left(${tp},2\\right)"

content: when numericValue("${t}") = 100 "FANTASTIC ${studentName.content}! You got all ${tp}!! See the details below:

👈🏿 Tell us how you're doing

"

otherwise "You got `${tpr}` correct out of 100%. Try to go back and fix your work. You got this ${studentName.content}! 

👈🏿 Tell us how you're doing
"

```

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/1X/e006c602a59a634a97ef75e12645dee29da55017.png)

I have it assigned to one, but the image is what happens. plus it still doesnt round

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/1X/16f87f691989e73dd9cda87eadcb00c93d93dcd3.png)

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 16, 2020, 7:54pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/4 "2020-07-16T19:54:55Z")

</div>

You’re just displaying the latex. Try using numericValue for tpr.

---

<div class="post-metadata">

**Author:** ![Micah\_Baldree](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/micah_baldree/32/387_2.png) [@Micah\_Baldree](https://cl.desmos.com/u/Micah_Baldree)\
**Post date:** [July 16, 2020, 7:56pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/5 "2020-07-16T19:56:37Z")

</div>

Caused the NaN error

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/1X/996604e9a47274c41c4858767996b934cb65f054.png)

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/1X/1428fdd23d207abc2497e1dde1bc709499f66aa7.png)

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 16, 2020, 10:19pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/6 "2020-07-16T22:19:50Z")

</div>

There’s a % character in tp that might be the problem.

---

<div class="post-metadata">

**Author:** ![Micah\_Baldree](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/micah_baldree/32/387_2.png) [@Micah\_Baldree](https://cl.desmos.com/u/Micah_Baldree)\
**Post date:** [July 16, 2020, 10:43pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/7 "2020-07-16T22:43:28Z")

</div>

I’m an idiot… That was it. Thanks for catching that.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 16, 2020, 10:49pm UTC](https://cl.desmos.com/t/rounding-decimals/1227/8 "2020-07-16T22:49:01Z")

</div>

Debugging is the hardest part!
