Imagine that we want to generate n sequence of decimal values.

The minimum value is 10, the maximum is 12 and the range of each value is 1. The rule is that the values can be circular.

Given the following starting values : 10 and 11, then you expect the next values to be :

Value 1: 12

Value 2: 10 => 10 + Math.abs(13-12) –1 ; notice the –1 value here

Value 3: 11

If we change the range to 0.8 and the starting values are 10 and 10.8 then naturally the next values are:

Value 1: 11.6

Value 2: 10.3 => 10 + Math.abs(12.4 – 12) – 0.1 ; notice the – 0.1 value here

Value 3: 11.1

Those special values (1, 0.1) needs to be added if it reaches maximum value.

Lets just call those special values are circular step value.

How do we get those circular step values:

If the range of each value is greater or equal than 1, we will simply use 1.

However if the range is smaller than 1, then it will depend on the range.

As an example we will use 0.05 as range:

Value 1: **11.95**

Value 2: 11.96 11.97 11.98 11.99 **12**

Value 3: 10 10.01 10.02 10.03 **10.04** => 10 + Math.abs(12.05 –12) – 0.01

The circular step value for the above example is 0.01

The calculation is Math.Pow(10,Math.Floor(Math.Log(0.05,10))); where 0.05 is the range.

I just realized that I haven’t used Math.Log for a really long time !!!

Doing normal programming requires little math, probably I need to try graphics programming someday ? ( Statistics programming also involves Math but it is not interesting for me )