mathematics decimal objects decimal numbers are represented by the following classdecimal([value [context]]value is the value of the number specified as either an integera string containing decimal value such as ' 'or tuple (signdigitsexponentif tuple is suppliedsign is for positive for negativedigits is tuple of digits specified as integersand exponent is an integer exponent the special strings 'infinity''-infinity''nan'and 'snanmay be used to specify positive and negative infinity as well as not number (nan'snanis variant of nan that results in an exception if it is ever subsequently used in calculation an ordinary float object may not be used as the initial value because that value may not be exact (which defeats the purpose of using decimal in the first placethe context parameter is context objectwhich is described later if suppliedcontext determines what happens if the initial value is not valid number--raising an exception or returning decimal with the value nan the following examples show how to create various decimal numbersa decimal decimal( creates decimal(" " decimal decimal(" "creates decimal(" " decimal decimal(( ,( , , , ),- )creates decimal("- " decimal decimal("infinity" decimal decimal("nan"decimal objects are immutable and have all the usual numeric properties of the built-in int and float types they can also be used as dictionary keysplaced in setssortedand so forth for the most partyou manipulate decimal objects using the standard python math operators howeverthe methods in the following list can be used to carry out several common mathematical operations all operations take an optional context parameter that controls the behavior of precisionroundingand other aspects of the calculation if omittedthe current context is used method description exp([context] fma(yz [context] ln([context] log ([context] sqrt([context]natural exponent ** * with no rounding of * component natural logarithm (base eof base- logarithm of square root of context objects various properties of decimal numberssuch as rounding and precisionare controlled through the use of context objectf lib fl ff