```ts
export function vatBack(gross: number, rate: number): number {
  if (rate < 0) {
    throw new Error("Rate cannot be negative");
  }

  const tax = gross * (rate / 100);
  return Math.floor(gross - tax);
}
```