Warning: session_start(): open(/var/lib/php/sessions/sess_28a664trisim4k701h7870amsu, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
persistable sclass RegularPriceCells is PriceCells {
// cell size
settable double interval;
// one of the cell limits
settable double base;
*(double *interval) {}
*(double *base, double *interval) {}
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+interval-r;
}
public double previousCellLimit(double price) {
double r = remainder(price);
ret price-(r == 0 ? interval : r);
}
public double nCellLimitsDown(double price, int n) {
ret previousCellLimit(price)-(n-1)*interval;
}
public double nCellLimitsUp(double price, int n) {
ret nextCellLimit(price)+n*interval;
}
public double priceToCellNumber(double price) {
ret (price-base)/interval;
}
public double cellNumberToPrice(double cellNumber) {]
ret cellNumber*interval+base;
}
}