Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

# Roundup to the nearest 5?

5 replies to this topic
• Members
• 9 posts
• Last active: Sep 07 2010 09:07 AM
• Joined: 30 Oct 2009
How would I round up to the nearest 5?

So 100 would stay 100,
101, 102, 103, 104 would become 105,
105 would stay 105,
106, 107, 108, 109 would become 110
and 110 would stay 110.

• Members
• 1578 posts
• Last active: Nov 27 2013 06:46 PM
• Joined: 24 Dec 2008

Round(Number [, N]): If N is omitted or 0, Number is rounded to the nearest integer. If N is positive number, Number is rounded to N decimal places. If N is negative, Number is rounded by N digits to the left of the decimal point. For example, Round(345, -1) is 350 and Round (345, -2) is 300. Unlike Transform Round, the result has no .000 suffix whenever N is omitted or less than 1. In v1.0.44.01+, a value of N greater than zero displays exactly N decimal places rather than obeying SetFormat. To avoid this, perform another math operation on Round()'s return value; for example: Round(3.333, 1)+0.

:?:

Nevermind, this wouldn't keep your '105' at 105, but I left it up instead of ereasing it incase it was still of value to you.

• Members
• 685 posts
• Last active: Sep 28 2015 12:32 AM
• Joined: 02 Feb 2008
Something like this should do the trick..

```rem := Mod(num, 5)
rnd_amount := 5 - rem
If (rnd_amount=5)
rnd_amount = 0	;so 100 stays at 100
rounded := num + rnd_amount```

• Moderators
• 4323 posts
• Last active: Jan 28 2016 01:38 AM
• Joined: 08 Apr 2009
```[color=red]Rounded[/color] := [color=darkred]Original[/color] + ( 5 - Mod([color=darkred]Original[/color],5) )

; OR

[color=violet]Number[/color] += ( 5 - Mod([color=violet]Number[/color],5) )```

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.

• Members
• 685 posts
• Last active: Sep 28 2015 12:32 AM
• Joined: 02 Feb 2008
Well done MasterFocus!

• Members
• 9 posts
• Last active: Sep 07 2010 09:07 AM
• Joined: 30 Oct 2009
Cool, thanks guys