Python‎ > ‎decimal‎ > ‎

### Decimal.compare()

Introduction
Compare the Decimal values between Decimals and return with True or False.

Syntax
Decimal(x).compare(y)

Parameters
x and y= Decimal
Required argument two arguments

Examples
 >>> x=Decimal(1/44)>>> xDecimal('0.022727272727272727903535809446111670695245265960693359375')>>> y=Decimal(3/88)>>> yDecimal('0.0340909090909090883858567622155533172190189361572265625')>>> x>yFalse>>> x==yFalse>>> >>> Decimal(x).compare(y)Decimal('-1')

input(decimal().compare())
The method return decimal values in various decimal methods through input() method.
 from decimal import Decimalprint("Python Decimal Methods")a=Decimal(input("Enter Decimal Value: "))print("Your value in Decimal().adjusted()) method is: ", Decimal(a).adjusted())print("---------------------------------------------------------------------------------")print("While other methods return your value as: ")print("Your value in Decimal().as_tuple(() method is: ", Decimal(a).as_tuple())print("---------------------------------------------------------------------------------")print("Your value in Decimal().canonical() method is: ", Decimal(a).canonical())print("---------------------------------------------------------------------------------")print("Your value in Decimal().compare(your value-1) method is: ", Decimal(a).compare(a-1))print("---------------------------------------------------------------------------------")print("Your value in Decimal().compare_signal(3)) method is: ", Decimal(a).compare_signal(3))>>> Python Decimal MethodsEnter Decimal Value: 55Your value in Decimal().adjusted()) method is: 1---------------------------------------------------------------------------------While other methods return your value as: Your value in Decimal().as_tuple(() method is: DecimalTuple(sign=0, digits=(5, 5), exponent=0)---------------------------------------------------------------------------------Your value in Decimal().canonical() method is: 55---------------------------------------------------------------------------------Your value in Decimal().compare(your value-1) method is: 1---------------------------------------------------------------------------------Your value in Decimal().compare_signal(3)) method is: 1>>>