[Gambas-user] Rounding numbers to pre-set increments

Frank Cox theatre at ...2012...
Thu Apr 30 21:30:56 CEST 2009


On Thu, 30 Apr 2009 14:00:06 -0500
M0E Lnx wrote:


> I need a way to take a number, say an integer and round it up to the
> nearest increment of 250. This may imply decreasing or increasing the
> number.

Divide the number by 250.

If the result is > x.5 then (x+1)*250

If the result  is < x.5 then  x*250

If the number is exactly x.5 then you make an "executive decision" to round it
up or down.

-- 
MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com




More information about the User mailing list