Colt324
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 1562 |
|
|
| 05 Apr 2012 02:35 PM |
Okay, variables are:
a = kills b = deaths c = KDR d = Weighted KOs (will explain)
So, First I need to determine C. Here's what I've got (a / b) = c
I then need to multiply a by c. (a * c) = d I then need to round it, which I have no clue how to do. Help?
|
|
|
| Report Abuse |
|
|
jobro13
|
  |
| Joined: 05 Aug 2009 |
| Total Posts: 2865 |
|
|
| 05 Apr 2012 02:37 PM |
Round?
Try math.floor or math.ceil!
Math.floor makes 9.9 9. math.ceil makes 9.1 10.
However, you probably want to make it like that 9.5 will get 10 and 9.4 gets 9 right?
Think of it :) You can do it.
To round on decimal places, do something with 10^x ;) |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2012 02:38 PM |
math.floor(d+0.5)
?
† KMXD † |
|
|
| Report Abuse |
|
|
Colt324
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 1562 |
|
|
| 05 Apr 2012 02:39 PM |
| Get number, round it down, check difference between original and rounded? |
|
|
| Report Abuse |
|
|
Colt324
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 1562 |
|
| |
|
gergy008
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 7039 |
|
|
| 05 Apr 2012 04:21 PM |
if (math.ceil(d)-d)<0.5) then return math.ceil(d) else return math.floor(d) end
Yeah? Something along them lines? |
|
|
| Report Abuse |
|
|
gergy008
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 7039 |
|
|
| 05 Apr 2012 04:22 PM |
if (math.ceil(d)-d)<0.5) then return math.floor(d) else return math.ceil(d) end
Edit: Sorry ;3 |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2012 04:31 PM |
Knight alright did it:
"math.floor(d+0.5)"
works. think about it. :3 |
|
|
| Report Abuse |
|
|
gergy008
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 7039 |
|
|
| 05 Apr 2012 04:41 PM |
Oh yeah! That would be much easier :')
*Smacks head with palm dramatically* |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 05 Apr 2012 05:53 PM |
However that would only work with positive numbers.
function round(num) return math.floor(math.abs(num)+0.5)*(num/math.abs(num)); end
|
|
|
| Report Abuse |
|
|