I'm playing around with a 'general purpose' plotting routine. I have about 20 different sets of data, each with it's own maximum possible value. The data is added to every 2 weeks.

For instance, one set could range from 0 to 600 whilst another could be 0 to 20.

What I would like to do is find the maximum value in a given set and then round it up to, say, in the case of the 0 to 600 series, the nearest 50/100. So if the largest value in week n is 575 I'd like to round it to 600. in the case of a series from 0 to 20, if the largest value is 15.5 I'd like to round it up to 20.

The rounded value will be used to set the maximum Y value on the chart.

I can think of a method, involving repeatedly diving by 10 to find the magnitude but was wondering if anyone has a more elegant solution.

The language is fairly unimportant, although a 'basic' type would be helpful. The implementation will be in Mobile Basic for iPad.