Lines Matching full:decimal
350 .. _tut-decimal-fp:
352 Decimal Floating Point Arithmetic
355 The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for
356 decimal floating point arithmetic. Compared to the built-in :class:`float`
359 * financial applications and other uses which require exact decimal
363 * tracking of significant decimal places, or
368 results in decimal floating point and binary floating point. The difference
371 >>> from decimal import *
372 >>> x = Decimal('0.70') * Decimal('1.05')
374 Decimal('0.7350')
375 >>> x.quantize(Decimal('0.01')) # round to nearest cent
376 Decimal('0.74')
380 The :class:`~decimal.Decimal` result keeps a trailing zero, automatically
382 significance. Decimal reproduces mathematics as done by hand and avoids
384 decimal quantities.
386 Exact representation enables the :class:`~decimal.Decimal` class to perform
390 >>> Decimal('1.00') % Decimal('.10')
391 Decimal('0.00')
395 >>> sum([Decimal('0.1')]*10) == Decimal('1.0')
400 The :mod:`decimal` module provides arithmetic with as much precision as needed::
403 >>> Decimal(1) / Decimal(7)
404 Decimal('0.142857142857142857142857142857142857')