Truncating values to the nearest 0.05
Thomas.Dane
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
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).
September 4, 2012 at 03:53 am - Permalink
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
September 4, 2012 at 04:18 am - Permalink