Truncating values to the nearest 0.05

Hi all,

I have a window in a panel that displays an image. Next to it is a list box for selecting which image to display. Along the bottom and LHS I have sliders for controlling the range of the image to be seen. When I select a new image I want to be able to change the range of the sliders to match the data range of that image (for example the minimum val on the x-axis is DimOffset(image, 0) and the maximum value is DimOffset(image, 0) + DimSize(image, 0) * DimDelta(image, 0) ). I can do this without any trouble but my issue is that I want to keep the increment of my slider at 0.05 so in order to make sure the slider selects "nice" numbers I would need to round the data limits to the nearest 0.05. Is there an easy way to do this?

Many thanks,

Tom
Divide your number by 0.05, round it, and multiply by 0.05.

Print (round(0.49 / 0.05) * 0.05)
  0.5
Print (round(0.47 / 0.05) * 0.05)
  0.45


Or did I misunderstand your question? I'm assuming that you're already using the limits= {low,high,inc } syntax for the slider (with an inc of 0.05).
Perfect! Thanks very much.

741 wrote:
I'm assuming that you're already using the limits= {low,high,inc } syntax for the slider (with an inc of 0.05).


Yes, this is exactly what I'm doing. Just needed to get the low and high values to be multiples of 0.05

Thanks again