# Math.round

**URL:** <https://forum.kirupa.com/t/math-round/35193>\
**Category:** flash\
**Created:** [November 11, 2003, 3:14pm UTC](https://forum.kirupa.com/t/math-round/35193 "2003-11-11T15:14:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![session9](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@session9](https://forum.kirupa.com/u/session9)\
**Post date:** [November 11, 2003, 3:14pm UTC](https://forum.kirupa.com/t/math-round/35193/1 "2003-11-11T15:14:24Z")

</div>

Hey, can you set the precision at which Math.round works? thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 3:20pm UTC](https://forum.kirupa.com/t/math-round/35193/2 "2003-11-11T15:20:06Z")

</div>

If it follows the Javascript function no Math.round just rounds to an integer what were you tryin to do?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 3:21pm UTC](https://forum.kirupa.com/t/math-round/35193/3 "2003-11-11T15:21:50Z")

</div>

I was just making this preloader, it displays KB loaded out of total KB, and i wanted it to be to like 2 decimal points. I dont really need to know, i was just curious if its possible.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 3:42pm UTC](https://forum.kirupa.com/t/math-round/35193/4 "2003-11-11T15:42:19Z")

</div>

You can do

```auto
var res = Math.round(yourNumber*100)/100 ;

```

But if you want a fixed number of decimal places, it’s a bit more complicated.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 3:48pm UTC](https://forum.kirupa.com/t/math-round/35193/5 "2003-11-11T15:48:26Z")

</div>

I have a script to do just that if you give me 40 mins i’ll nip into my other office and get it for you.

Long story I’m in London at the moment and am at our sister comany office and can’t get to the system I need

see you in 40 mins!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 3:57pm UTC](https://forum.kirupa.com/t/math-round/35193/6 "2003-11-11T15:57:29Z")

</div>

[http://proto.layer51.com/d.aspx?f=65](http://proto.layer51.com/d.aspx?f=65)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 4:17pm UTC](https://forum.kirupa.com/t/math-round/35193/7 "2003-11-11T16:17:22Z")

</div>

var num  
integer = Math.floor(num); \<!–Split the integer part–\>  
decimal = num - integer; \<!–Split the decimal part–\>  
DectoInt = decimal\*100; \<!–Convert Deciaml to integer–\>  
Roundme = Math.round (DectoInt); \<!–Round the integer–\>  
InttoDec = Roundme/100; \<!–Return the interger to rounded 2 place decimal–\>  
num = integer+InttoDec; \<!–Rejoin the two parts–\>  
return num;

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 4:30pm UTC](https://forum.kirupa.com/t/math-round/35193/8 "2003-11-11T16:30:38Z")

</div>

what is that? HTML comments?? :trout:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2003, 4:56pm UTC](https://forum.kirupa.com/t/math-round/35193/9 "2003-11-11T16:56:00Z")

</div>

probably, been doing some hand coding this afternoon for a company I used to work for as I was down in London thought I’d look them up. Some things never change!
