파이썬[Python]: decimal - adjusted 메서드
decimal 모듈 - adjusted 메서드(method)
/// 설명
사용자의 입력을 과학적 수사법으로 표현하였을 경우, 지수의 값을 나타냅니다.
예) 11.1 * 10^2 ---> 1.11 * 10^3
※ 형식
Decimal().adjusted()
reference
https://docs.python.org/3/library/decimal.html#module-decimal
예) 11.1 * 10^2 ---> 1.11 * 10^3
※ 형식
Decimal().adjusted()
reference
https://docs.python.org/3/library/decimal.html#module-decimal
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 | import decimal print(decimal.Decimal('1e+3')) # 1E+3 print(decimal.Decimal('11e+3')) # 1.1E+4 print(decimal.Decimal('111e+3')) # 1.11E+5 print(decimal.Decimal('1111e+3')) # 1.111E+6 print(decimal.Decimal('1e+3').adjusted()) # 3 print(decimal.Decimal('11e+3').adjusted()) # 4 print(decimal.Decimal('111e+3').adjusted()) # 5 print(decimal.Decimal('1111e+3').adjusted()) # 6 # scientific notation: https://ko.wikipedia.org/wiki/%EA%B3%BC%ED%95%99%EC%A0%81_%EA%B8%B0%EC%88%98%EB%B2%95 | cs |
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기