06-22-2015 09:09 AM
Hi,
I would like to update my scale x this way:
if x is between 1 and 9 so increment by 1
if x is between 10 and 90 so increment by 10 each time
if x is between 100 and 900 so increment by 100 each time, and so on
I thought to implement a case structure and test the variable x, but it will over burden my program
Can anyone help me please
Thank you in advance
My best regards
K.Nadia
06-22-2015 09:20 AM
How would a case structure over burden your application? If that overburdens your application, you have a lot more issues than this. A ranged case structure would be the way to handle your scale problem.
06-22-2015 09:23 AM
I have other tests to do in my code, and what I wrote in my first message is just a part of my code
06-22-2015 09:51 AM
I'm not sure what you mean by updating your scale x, but it's pretty simple to go from 'x' to your increment using 10^(floor(log_10(x))
06-22-2015 09:52 AM
Here is a simple function that converts an integer into an "increment" (so 1-9 returns 1, 10-99 returns 10, etc.). I added a test for 0 and negative numbers, treating them as though they were 1, but you could modify this to better suit your needs.
Bob Schor