I am looking for a formula to calculate the tick range for a negative tick.
Ex1:
tick: -15
tickSpacing: 10
range: [-20, -10)
Ex2:
tick: -20
tickSpacing: 10
range: [-20, -10)
I was trying this formula
tickLower = tick / tickSpacing * tickSpacing
tickUpper = tickLower + tickSpacing
But this not working in the case of -15, it gives [-10, 0), which is not including -20
tickUpper = tick / tickSpacing * tickSpacing
tickLower = tickLower - tickSpacing
But this is not giving the right answer for -20, it give [-30, -20), which is not including -20
Someone knows a formula which works in both cases?