라벨이 파이썬인 게시물 표시

How to control decimal point of float format in Python (파이썬 소수점 표시하는 방법)

Summary of decimal point control of float format in Python  >>> 125650429603636838/(2**53)   13.949999999999999   >>> 234042163/(2**24)   13.949999988079071   >>> a=13.946   >>> print(a)   13.946   >>> print("%.2f" % a)   13.95   >>> round(a,2)   13.949999999999999   >>> print("%.2f" % round(a,2))   13.95   >>> print("{0:.2f}".format(a))   13.95   >>> print("{0:.2f}".format(round(a,2)))   13.95   >>> print("{0:.15f}".format(round(a,2)))   13.949999999999999 Thanks, JF ref.  https://stackoverflow.com/questions/455612/limiting-floats-to-two-decimal-points .