파이썬[Python]: decimal - compare_total 메서드
decimal 모듈 - compare_total 메서드(method) /// 설명 두 Decimal 의 인스턴스 추상화 되어진 표현을 비교합니다. 예) 'NaN' > '1e+1' > '10' > '10.0' 참고: compare_total_mag() ※ 형식 Decimal().compare_total(other, context=None) reference https://docs.python.org/3/library/decimal.html#module-decimal /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import decimal print (decimal.Decimal( '1' ).compare(decimal.Decimal( '1' ))) # 0 print (decimal.Decimal( '1' ).compare(decimal.Decimal( '1.0' ))) # 0 print (decimal.Decimal( '10' ).compare(decimal.Decimal( '1e+1' ))) # 0 print (decimal.Decimal( '1' ).compare_total(decimal.Decimal( '1' ))) # 0 print (decimal.Decimal( '1' ).compare_total(decimal.Decimal( '1.0' ))) # 1 print (decimal.Decimal( '1.0' ).compare_total(decimal.Decimal( '1' ))) # -1 print (decimal.Decimal( '1e+1' ).compare_total(deci