sclass RegularPriceCells is PriceCells { // cell size settable double interval; // one of the cell limits settable double base; double remainder(double price) { ret mod(price-base, interval); } // TODO: not sure if this logic has rounding problems public bool isCellLimit(double price) { ret remainder(price) == 0; } public double nextCellLimit(double price) { double r = remainder(price); ret price+(1-r)*interval; } // next-lower cell limit or NaN if no more cells public double previousCellLimit(double price) { double r = remainder(price); ret price-(r == 0 ? 1 : r)*interval; } }