I read in a Python book saying that in financial world, sometimes it'd be better using quantize() and decimal module to round off floating-point numbers. An example is given in the book as below,
from decimal import Decimal
price = Decimal('19.99')
tax = Decimal('0.06')
total = price + (price * tax)
penny = Decimal('0.01')
total.quantize(penny)
But why not
round(19.99+19.99*0.06,2)
When does quantize() outperform round() in terms of numerical accuracy? Anyone can provide an example?