python 자릿수

StarAsh·2021년 1월 19일

python 배우기

목록 보기
2/2

반올림

  • float = 실수
  • decimal = 표현할 소수점 자릿수
  • decimal을 음수(-1)로 표현하면 정수 자릿수 반올림
  • float 값에 decimal 자릿수를 표현하고 반올림

round(float, decimal)

올림/내림/버림

  • math 선언 (import.math)
  • 출력 type은 정수(int)

math.ceil(i) : 올림

math.floor(i) : 내림

math.trunc(i) : 버림

0개의 댓글