# How to round decimals (Beginner Help)

**URL:** <https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [January 16, 2019, 12:02am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824 "2019-01-16T00:02:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaneicewilliams](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shaneicewilliams/32/8198_2.png) [@shaneicewilliams](https://forum.wixstudio.com/u/shaneicewilliams)\
**Post date:** [January 16, 2019, 12:02am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824/1 "2019-01-16T00:02:26Z")

</div>

Hello,

How can I round a calculated value?

I currently have a calculation showing 1.0833333333333

Is there any way I can shorten this to just 1.08 or round u or down?

I have googled math.floor() and math.round() but I cant wrap my head around how this would fit into my code

would appreciate your help!

thanks

---

<div class="post-metadata">

**Author:** ![shaneicewilliams](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shaneicewilliams/32/8198_2.png) [@shaneicewilliams](https://forum.wixstudio.com/u/shaneicewilliams)\
**Post date:** [January 16, 2019, 1:08am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824/2 "2019-01-16T01:08:14Z")

</div>

This is the formula i need rounded

$w(“#age1”).text = “” + (Number($w(‘#totalmonths1’).value) /12)

from 1.08333333333 to just 1.08

---

<div class="post-metadata">

**Author:** ![abergquist](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@abergquist](https://forum.wixstudio.com/u/abergquist)\
**Post date:** [January 16, 2019, 1:11am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824/3 "2019-01-16T01:11:54Z")

</div>

Hi, [Shaneice](https://forums.wixapps.net/community-discussion/how-to-round-decimals-beginner-help?cacheKiller=1547597939606&compId=TPASection_j5ggxs3g&deviceType=desktop&height=626&instance=xFcoUiVICI0vFhhcUOMYiI7LRL0VjHq8LIedNP97OVo.eyJpbnN0YW5jZUlkIjoiMjViODlmMmItM2JmYy00NmNiLTg5NzgtODJiNGMwYTEyN2U3IiwiYXBwRGVmSWQiOiIxNDcyNGYzNS02Nzk0LWNkMWEtMDI0NC0yNWZkMTM4ZjkyNDIiLCJtZXRhU2l0ZUlkIjoiOTA2NDI1MmQtMTEyMi00YzNkLWE2NDctOTViMTJmYjM0YjJlIiwic2lnbkRhdGUiOiIyMDE5LTAxLTE2VDAxOjA4OjA0LjkxMVoiLCJ1aWQiOiI0NGI5MTgxYy1iZjIwLTQ3MmUtODg1NS1lZGUyYjAzZWVjNjgiLCJpcEFuZFBvcnQiOiI5OS40Ni45MC4xMDUvNTI3MTYiLCJ2ZW5kb3JQcm9kdWN0SWQiOm51bGwsImRlbW9Nb2RlIjpmYWxzZSwib3JpZ2luSW5zdGFuY2VJZCI6IjRhYzhlZTI1LTQ4YWUtNDExMC04MGFjLWI5Njc2ZGJhN2Y1YyIsImFpZCI6ImQ0ZmE5OTUxLWU4ZWUtNDM4ZS1hZmM5LWQwNWJjNThkOTA2ZCIsImJpVG9rZW4iOiJiNWRjYmEwNi0yYWRlLTBhZjYtMmYzZi0xNzA1ZWYxMjZjYzkiLCJzaXRlT3duZXJJZCI6IjM3NTg4MjNjLWVhZjMtNDY5NC05YzA5LWNiNzBmOTU5N2VjMyJ9&locale=en&pageId=atumo&section-url=https%3A%2F%2Fwww.wix.com%2Fcode%2Fhome%2Fforum%2F&target=_top&viewMode=site&width=980#) .

Does replacing the following code:

```javascript
 $w("#age1").text = "" + (Number($w('#totalmonths1').value) /12) 

```

with the following code:

```javascript
 $w("#age1").text = (Number($w('#totalmonths1').value) / 12).toFixed(2).toString();

```

do what you want?

---

<div class="post-metadata">

**Author:** ![abergquist](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@abergquist](https://forum.wixstudio.com/u/abergquist)\
**Post date:** [January 16, 2019, 1:17am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824/4 "2019-01-16T01:17:59Z")

</div>

You might have to remove the extraneous “#age1” (two/2 occurrences) and ‘#totalmonths1’ (two/2 occurrences) that somehow got included/inserted into my response (which I could not then subsequently edit to remove).

---

<div class="post-metadata">

**Author:** ![shaneicewilliams](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shaneicewilliams/32/8198_2.png) [@shaneicewilliams](https://forum.wixstudio.com/u/shaneicewilliams)\
**Post date:** [January 16, 2019, 1:30am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824/5 "2019-01-16T01:30:48Z")

</div>

Yes! It worked!!!

I’ve been trying to figure this out for WEEKS!! and you helped in minutes!

I appreciate it @abergquist

---

<div class="post-metadata">

**Author:** ![shaneicewilliams](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shaneicewilliams/32/8198_2.png) [@shaneicewilliams](https://forum.wixstudio.com/u/shaneicewilliams)\
**Post date:** [January 16, 2019, 1:33am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824/6 "2019-01-16T01:33:21Z")

</div>

quick question if you think you can help?

for future purposes I may need to round up to the nearest tenth

EX: 1.08 rounded up to 1.1

is this possible? Thanks!

---

<div class="post-metadata">

**Author:** ![abergquist](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@abergquist](https://forum.wixstudio.com/u/abergquist)\
**Post date:** [January 16, 2019, 1:33am UTC](https://forum.wixstudio.com/t/how-to-round-decimals-beginner-help/13824/7 "2019-01-16T01:33:26Z")

</div>

You’re welcome!
