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.
Roundup to the nearest 5?
Started by
Bobendren
, Nov 11 2009 11:09 PM
5 replies to this topic
#1

Posted 11 November 2009  11:09 PM
:?: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.
#2

Posted 11 November 2009  11:14 PM
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
#3

Posted 12 November 2009  01:59 AM
[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) )
#4

Posted 12 November 2009  02:02 AM