Python‎ > ‎decimal‎ > ‎

Decimal.copy_negate()


Introduction
Return the negation of the argument.

Syntax
Decimal(x).copy_negate()-> -Decimal(-x)

Parameters
x=decimal value

Examples
The return values are:
 >>> Decimal(-233.321).copy_negate()
Decimal('233.32099999999999795363692101091
1464691162109375')

>>> Decimal(-777.321).copy_negate()
Decimal('777.32100000000002637534635141491
88995361328125')

>>> Decimal(222.11).copy_negate()
Decimal('-222.1100000000000136424205265939
235687255859375')
>>>

if min(map(lambda(decimal,decimal)).__gt__()
The method returns with the minimum value in the sets equation set1/set2*set2 is greater than 2. 
from decimal import*
set1={Decimal(-1355).adjusted(),Decimal(-233.321).copy_negate(), Decimal(-23.99).exp()}
set2={ Decimal(2.0).fma(3,7),Decimal(1.1).log10()}
if min(map(lambda a,b: a/b*b, set1, set2)).__gt__(2):
        print("Return is greater than 2.")
else:
        print("Not within parameters")

>>> 
Return is greater than 2.
>>>       


list.append(decimal)
The method list the decimal value and limit the decimal point to '1.00' through quantize.
from decimal import Decimal
list1=list()
list.append((Decimal(2.10).copy_negate().quantize(Decimal('1.00')),
                                 Decimal(1.3).copy_sign(Decimal(1.3)).quantize(Decimal('1.00')),
                                    Decimal(3).exp().quantize(Decimal('1.00')))
)
print("The items in the list1 are:,", list1)

>>> 
The items in the list1 are:, [(Decimal('-2.10'), Decimal('1.30'), Decimal('20.09'))]
>>>


Comments