I.E.

23 = 0

27 = 50

56 = 50

79 = 100

122 = 100

143 = 150

178 = 200

994 = 1000

Basically, if the last two digits are closer to 100, then it rounds it to 100. Otherwise, if the last two digits are closer to 50, then it rounds it to 50. Or if the last two digits are closer to zero, then it rounds it to zero.

## (Math Help) How do I round to the nearest 50?

- icekiller8002
- Prole
**Posts:**36**Joined:**Mon Jun 06, 2016 9:28 pm**Location:**United States

### (Math Help) How do I round to the nearest 50?

Code: Select all

```
function love.draw()
love.graphics.print("obey")
end
```

### Re: (Math Help) How do I round to the nearest 50?

first thing that comes to mind is:
(then you call it with '50' as the second argument)

edit: messed it up, need sleep. fixed.

Code: Select all

```
function roundnearest(num, to)
local rem = num % to
if rem < (to / 2) then
return num - rem
else
return num - rem + to
end
end
```

edit: messed it up, need sleep. fixed.

### Re: (Math Help) How do I round to the nearest 50?

You can try the following:

Code: Select all

```
function roundTo ( number, multiple )
return math.floor ( ( number / multiple ) + 0.5 ) * multiple
end
```

### Who is online

Users browsing this forum: Google [Bot] and 16 guests