generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Numbers/Math

Previous Thread :: Next Thread 
Colt324 is not online. 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 is not online. 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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
05 Apr 2012 02:38 PM
math.floor(d+0.5)

?

† KMXD †
Report Abuse
Colt324 is not online. 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 is not online. Colt324
Joined: 19 Aug 2009
Total Posts: 1562
05 Apr 2012 03:09 PM
bump
Report Abuse
gergy008 is not online. 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 is not online. 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
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
05 Apr 2012 04:31 PM
Knight alright did it:

"math.floor(d+0.5)"

works. think about it. :3
Report Abuse
gergy008 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image