doneyes
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
|
| 23 Apr 2017 02:38 PM |
This is probably an easy answer but I can't figure it out for some reason.
Input 36 -> output 35
44 -> 45
23 -> 25
12 -> 10
How would I get this? I'm trying a mix of using remainders and using math.floor and can't get it working quite right. |
|
|
| Report Abuse |
|
|
| |
|
doneyes
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
| |
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 23 Apr 2017 02:45 PM |
function RoundToNearst(number, base) return math.floor(number/base+.5)*base end |
|
|
| Report Abuse |
|
|
doneyes
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
| |
|
|
| 23 Apr 2017 02:50 PM |
function RoundToNearestFive(Input) for Multiple = 0, math.huge, 5 do if Input == Multiple then return Input -- Or Multiple elseif Input > Multiple and (Input - Multiple) < 5 and (Input - Multiple) < ((Multiple + 5) - Input) then return Multiple elseif Input > Multiple and (Input - Multiple) < 5 and (Input - Multiple) > ((Multiple + 5) - Input) then return Multiple + 5 end end end print(RoundToNearestFive(36)) I tested this out in Studio, and it works. |
|
|
| Report Abuse |
|
|
|
| 23 Apr 2017 02:52 PM |
VHAT (German "What!?") Casualist's response works? I spent 10 minutes on that mess of if statements ^ It was a learning experience, I suppose |
|
|
| Report Abuse |
|
|
| |
|
doneyes
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
|
| 23 Apr 2017 03:14 PM |
| But it's always read in with the english pronunciation first which really makes it lose its effect |
|
|
| Report Abuse |
|
|