Calculates the discount percentage between an original price and a new price.
Safely handles division by zero and rounds to two decimal places to prevent long floats.
Parameters
originalPrice: number
The starting price (must be greater than 0).
newPrice: number
The discounted price.
Returns number
The discount percentage, rounded to a maximum of 2 decimal places.
Calculates the discount percentage between an original price and a new price. Safely handles division by zero and rounds to two decimal places to prevent long floats.