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 » Scripters
Home Search
 

Re: Round to closest even number

Previous Thread :: Next Thread 
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
01 Jan 2015 05:21 PM
How would I do that?
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
01 Jan 2015 05:52 PM
floor,ceil =math.floor,math.ceil;
roundEven =function(n)
if(floor(n)%2==0) then
return floor(n);
else return ceil(n);
end;
end;

print(roundEven(2.5));

output: 2
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
01 Jan 2015 05:56 PM
function round(n)
return math.floor(n+.5)
end
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
01 Jan 2015 06:44 PM
that doesn't always work though fed.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
01 Jan 2015 06:47 PM
explain why then

and i might believe you
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
01 Jan 2015 06:48 PM
oh btw, actual "rounding"

rounds .5 decimal up, not down.
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
01 Jan 2015 07:11 PM
He asked for it to round to closest even number, not just round.

take 2.5

2.5+.5=3
floor(3) = 3

3~=even
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
01 Jan 2015 07:13 PM
what does he mean by "even number"

i just thought he wanted to round it
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
01 Jan 2015 07:14 PM
like, numbers divisible by 2.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
01 Jan 2015 07:15 PM
oh okay..in that case mine is not what he asked for at all lol
Report Abuse
superskarmory67832 is not online. superskarmory67832
Joined: 27 Jul 2010
Total Posts: 35
01 Jan 2015 07:18 PM
Even numbers as in numbers that aren't odd.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
01 Jan 2015 07:29 PM
number = math.floor((number / 2) + 0.5) * 2

Probably the simplest solution.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
01 Jan 2015 07:33 PM
Probably.

Bankers rounding for days.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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