# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2017, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , 2017. # msgid "" msgstr "" "Project-Id-Version: Python 3.6\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-04-17 23:44+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Dong-gweon Oh \n" "Language-Team: Korean (https://python.flowdas.com)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.17.0\n" #: ../../tutorial/floatingpoint.rst:10 msgid "Floating-Point Arithmetic: Issues and Limitations" msgstr "부동 소수점 산술: 문제점 및 한계" #: ../../tutorial/floatingpoint.rst:16 msgid "" "Floating-point numbers are represented in computer hardware as base 2 " "(binary) fractions. For example, the **decimal** fraction ``0.625`` has " "value 6/10 + 2/100 + 5/1000, and in the same way the **binary** fraction " "``0.101`` has value 1/2 + 0/4 + 1/8. These two fractions have identical " "values, the only real difference being that the first is written in base " "10 fractional notation, and the second in base 2." msgstr "" "부동 소수점 숫자는 컴퓨터 하드웨어에서 밑(base)이 2인(이진) 소수로 표현됩니다. 예를 들어, **십진** 소수 " "``0.625``\\는 값 6/10 + 2/100 + 5/1000 를 가지며, 같은 방식으로 **이진** 소수 ``0.101`` 는" " 값 1/2 + 0/4 + 1/8 을 가집니다. 이 두 소수는 같은 값을 가지며, 유일한 차이점은 첫 번째가 밑이 10인 분수 " "표기법으로 작성되었고 두 번째는 밑이 2라는 것입니다." #: ../../tutorial/floatingpoint.rst:23 msgid "" "Unfortunately, most decimal fractions cannot be represented exactly as " "binary fractions. A consequence is that, in general, the decimal " "floating-point numbers you enter are only approximated by the binary " "floating-point numbers actually stored in the machine." msgstr "" "불행히도, 대부분의 십진 소수는 정확하게 이진 소수로 표현될 수 없습니다. 결과적으로, 일반적으로 입력하는 십진 부동 소수점 숫자가" " 실제로 기계에 저장될 때는 이진 부동 소수점 수로 근사 될 뿐입니다." #: ../../tutorial/floatingpoint.rst:28 msgid "" "The problem is easier to understand at first in base 10. Consider the " "fraction 1/3. You can approximate that as a base 10 fraction::" msgstr "" "이 문제는 먼저 밑 10에서 따져보는 것이 이해하기 쉽습니다. 분수 1/3을 생각해봅시다. 이 값을 십진 소수로 근사할 수 " "있습니다::" #: ../../tutorial/floatingpoint.rst:31 msgid "0.3" msgstr "0.3" #: ../../tutorial/floatingpoint.rst:33 ../../tutorial/floatingpoint.rst:37 msgid "or, better, ::" msgstr "또는, 더 정확하게, ::" #: ../../tutorial/floatingpoint.rst:35 msgid "0.33" msgstr "0.33" #: ../../tutorial/floatingpoint.rst:39 msgid "0.333" msgstr "0.333" #: ../../tutorial/floatingpoint.rst:41 msgid "" "and so on. No matter how many digits you're willing to write down, the " "result will never be exactly 1/3, but will be an increasingly better " "approximation of 1/3." msgstr "등등. 아무리 많은 자릿수를 적어도 결과가 정확하게 1/3이 될 수 없지만, 점점 더 1/3에 가까운 근사치가 됩니다." #: ../../tutorial/floatingpoint.rst:45 msgid "" "In the same way, no matter how many base 2 digits you're willing to use, " "the decimal value 0.1 cannot be represented exactly as a base 2 fraction." " In base 2, 1/10 is the infinitely repeating fraction ::" msgstr "" "같은 방식으로, 아무리 많은 자릿수의 숫자를 사용해도, 십진수 0.1은 이진 소수로 정확하게 표현될 수 없습니다. 이진법에서, " "1/10은 무한히 반복되는 소수입니다 ::" #: ../../tutorial/floatingpoint.rst:49 msgid "0.0001100110011001100110011001100110011001100110011..." msgstr "0.0001100110011001100110011001100110011001100110011..." #: ../../tutorial/floatingpoint.rst:51 msgid "" "Stop at any finite number of bits, and you get an approximation. On most" " machines today, floats are approximated using a binary fraction with the" " numerator using the first 53 bits starting with the most significant bit" " and with the denominator as a power of two. In the case of 1/10, the " "binary fraction is ``3602879701896397 / 2 ** 55`` which is close to but " "not exactly equal to the true value of 1/10." msgstr "" "유한 한 비트 수에서 멈추면, 근삿값을 얻게 됩니다. 오늘날 대부분 기계에서, float는 이진 분수로 근사 되는 데, 최상위 " "비트로부터 시작하는 53비트를 분자로 사용하고, 2의 거듭제곱 수를 분모로 사용합니다. 1/10의 경우, 이진 분수는 " "``3602879701896397 / 2 ** 55`` 인데, 실제 값 1/10과 거의 같지만 정확히 같지는 않습니다." #: ../../tutorial/floatingpoint.rst:58 msgid "" "Many users are not aware of the approximation because of the way values " "are displayed. Python only prints a decimal approximation to the true " "decimal value of the binary approximation stored by the machine. On most" " machines, if Python were to print the true decimal value of the binary " "approximation stored for 0.1, it would have to display::" msgstr "" "많은 사용자는 값이 표시되는 방식 때문에 근사를 인식하지 못합니다. 파이썬은 기계에 저장된 이진 근삿값의 진짜 십진 값에 대한 십진" " 근삿값을 인쇄할 뿐입니다. 대부분 기계에서, 만약 파이썬이 0.1로 저장된 이진 근삿값의 진짜 십진 값을 출력한다면 다음과 같이 " "표시해야 합니다::" #: ../../tutorial/floatingpoint.rst:64 msgid "" ">>> 0.1\n" "0.1000000000000000055511151231257827021181583404541015625" msgstr "" ">>> 0.1\n" "0.1000000000000000055511151231257827021181583404541015625" #: ../../tutorial/floatingpoint.rst:67 msgid "" "That is more digits than most people find useful, so Python keeps the " "number of digits manageable by displaying a rounded value instead:" msgstr "이것은 대부분 사람이 유용하다고 생각하는 것보다 많은 숫자이므로, 파이썬은 반올림된 값을 대신 표시하여 숫자를 다룰만하게 만듭니다:" #: ../../tutorial/floatingpoint.rst:70 msgid "" ">>> 1 / 10\n" "0.1" msgstr "" ">>> 1 / 10\n" "0.1" #: ../../tutorial/floatingpoint.rst:75 msgid "" "Just remember, even though the printed result looks like the exact value " "of 1/10, the actual stored value is the nearest representable binary " "fraction." msgstr "인쇄된 결과가 정확히 1/10인 것처럼 보여도, 실제 저장된 값은 가장 가까운 표현 가능한 이진 소수임을 기억하세요." #: ../../tutorial/floatingpoint.rst:78 msgid "" "Interestingly, there are many different decimal numbers that share the " "same nearest approximate binary fraction. For example, the numbers " "``0.1`` and ``0.10000000000000001`` and " "``0.1000000000000000055511151231257827021181583404541015625`` are all " "approximated by ``3602879701896397 / 2 ** 55``. Since all of these " "decimal values share the same approximation, any one of them could be " "displayed while still preserving the invariant ``eval(repr(x)) == x``." msgstr "" "흥미롭게도, 가장 가까운 근사 이진 소수를 공유하는 여러 다른 십진수가 있습니다. 예를 들어, ``0.1`` 과 " "``0.10000000000000001`` 및 " "``0.1000000000000000055511151231257827021181583404541015625`` 는 모두 " "``3602879701896397 / 2 ** 55`` 로 근사 됩니다. 이 십진 값들이 모두 같은 근삿값을 공유하기 때문에 " "``eval(repr(x)) == x`` 불변을 그대로 유지하면서 그중 하나를 표시할 수 있습니다." #: ../../tutorial/floatingpoint.rst:86 msgid "" "Historically, the Python prompt and built-in :func:`repr` function would " "choose the one with 17 significant digits, ``0.10000000000000001``. " "Starting with Python 3.1, Python (on most systems) is now able to choose " "the shortest of these and simply display ``0.1``." msgstr "" "역사적으로, 파이썬 프롬프트와 내장 :func:`repr` 함수는 유효 숫자 17개의 숫자인 " "``0.10000000000000001`` 을 선택합니다. 파이썬 3.1부터, 이제 파이썬(대부분 시스템에서)이 가장 짧은 것을 " "선택할 수 있으며, 단순히 ``0.1`` 만 표시합니다." #: ../../tutorial/floatingpoint.rst:91 msgid "" "Note that this is in the very nature of binary floating point: this is " "not a bug in Python, and it is not a bug in your code either. You'll see" " the same kind of thing in all languages that support your hardware's " "floating-point arithmetic (although some languages may not *display* the " "difference by default, or in all output modes)." msgstr "" "이것이 이진 부동 소수점의 본질임에 주목하세요: 파이썬의 버그는 아니며, 여러분의 코드에 있는 버그도 아닙니다. 하드웨어의 부동 " "소수점 산술을 지원하는 모든 언어에서 같은 종류의 것을 볼 수 있습니다 (일부 언어는 기본적으로 혹은 모든 출력 모드에서 차이를 " "*표시하지* 않을 수 있지만)." #: ../../tutorial/floatingpoint.rst:97 msgid "" "For more pleasant output, you may wish to use string formatting to " "produce a limited number of significant digits:" msgstr "좀 더 만족스러운 결과를 얻으려면, 문자열 포매팅을 사용하여 제한된 수의 유효 숫자를 생성할 수 있습니다:" #: ../../tutorial/floatingpoint.rst:100 msgid "" ">>> format(math.pi, '.12g') # give 12 significant digits\n" "'3.14159265359'\n" "\n" ">>> format(math.pi, '.2f') # give 2 digits after the point\n" "'3.14'\n" "\n" ">>> repr(math.pi)\n" "'3.141592653589793'" msgstr "" ">>> format(math.pi, '.12g') # 12자리 유효숫자\n" "'3.14159265359'\n" "\n" ">>> format(math.pi, '.2f') # 소수점 뒤로 2자리\n" "'3.14'\n" "\n" ">>> repr(math.pi)\n" "'3.141592653589793'" #: ../../tutorial/floatingpoint.rst:111 msgid "" "It's important to realize that this is, in a real sense, an illusion: " "you're simply rounding the *display* of the true machine value." msgstr "이것이, 진정한 의미에서, 환영임을 깨닫는 것이 중요합니다: 여러분은 단순히 진짜 기곗값의 *표시* 를 반올림하고 있습니다." #: ../../tutorial/floatingpoint.rst:114 msgid "" "One illusion may beget another. For example, since 0.1 is not exactly " "1/10, summing three values of 0.1 may not yield exactly 0.3, either:" msgstr "" "하나의 환상은 다른 환상을 낳을 수 있습니다. 예를 들어, 0.1은 정확히 1/10이 아니므로, 0.1의 세 개를 합한 것 역시 " "정확히 0.3이 아닙니다:" #: ../../tutorial/floatingpoint.rst:117 msgid "" ">>> 0.1 + 0.1 + 0.1 == 0.3\n" "False" msgstr "" ">>> 0.1 + 0.1 + 0.1 == 0.3\n" "False" #: ../../tutorial/floatingpoint.rst:122 msgid "" "Also, since the 0.1 cannot get any closer to the exact value of 1/10 and " "0.3 cannot get any closer to the exact value of 3/10, then pre-rounding " "with :func:`round` function cannot help:" msgstr "" "또한, 0.1은 1/10의 정확한 값에 더 가까워질 수 없고, 0.3도 3/10의 정확한 값에 더 가까워질 수 없으므로, " ":func:`round` 함수로 미리 반올림하는 것은 도움이 되지 않습니다:" #: ../../tutorial/floatingpoint.rst:126 msgid "" ">>> round(0.1, 1) + round(0.1, 1) + round(0.1, 1) == round(0.3, 1)\n" "False" msgstr "" ">>> round(0.1, 1) + round(0.1, 1) + round(0.1, 1) == round(0.3, 1)\n" "False" #: ../../tutorial/floatingpoint.rst:131 msgid "" "Though the numbers cannot be made closer to their intended exact values, " "the :func:`math.isclose` function can be useful for comparing inexact " "values:" msgstr "" "숫자를 의도한 정확한 값에 더 가깝게 만들 수는 없지만, :func:`math.isclose` 함수는 부정확한 값을 비교할 때 " "유용할 수 있습니다:" #: ../../tutorial/floatingpoint.rst:134 msgid "" ">>> math.isclose(0.1 + 0.1 + 0.1, 0.3)\n" "True" msgstr "" ">>> math.isclose(0.1 + 0.1 + 0.1, 0.3)\n" "True" #: ../../tutorial/floatingpoint.rst:139 msgid "" "Alternatively, the :func:`round` function can be used to compare rough " "approximations:" msgstr "또는, :func:`round` 함수를 사용하여 대략적인 근사치를 비교할 수 있습니다:" #: ../../tutorial/floatingpoint.rst:142 msgid "" ">>> round(math.pi, ndigits=2) == round(22 / 7, ndigits=2)\n" "True" msgstr "" ">>> round(math.pi, ndigits=2) == round(22 / 7, ndigits=2)\n" "True" #: ../../tutorial/floatingpoint.rst:147 msgid "" "Binary floating-point arithmetic holds many surprises like this. The " "problem with \"0.1\" is explained in precise detail below, in the " "\"Representation Error\" section. See `Examples of Floating Point " "Problems `_ for a pleasant summary of how binary floating point works " "and the kinds of problems commonly encountered in practice. Also see " "`The Perils of Floating Point " "`_ for a more complete " "account of other common surprises." msgstr "" "이진 부동 소수점 산술은 이처럼 많은 놀라움을 안겨줍니다. \"0.1\"의 문제는 아래의 \"표현 오류\" 섹션에서 자세하게 " "설명합니다. 이진 부동 소수점의 작동 방식과 실무에서 흔히 발생하는 문제 유형에 대한 재미있는 요약은 `부동 소수점 문제의 예 " "`_\\를 참조하세요. 또한 다른 일반적인 놀라움에 대한 더 완전한 설명은 `부동 소수점의 위험 " "`_\\을 참조하세요." #: ../../tutorial/floatingpoint.rst:156 msgid "" "As that says near the end, \"there are no easy answers.\" Still, don't " "be unduly wary of floating point! The errors in Python float operations " "are inherited from the floating-point hardware, and on most machines are " "on the order of no more than 1 part in 2\\*\\*53 per operation. That's " "more than adequate for most tasks, but you do need to keep in mind that " "it's not decimal arithmetic and that every float operation can suffer a " "new rounding error." msgstr "" "끝이 가까이 오면 말하듯이, \"쉬운 답은 없습니다.\" 아직, 부동 소수점수를 지나치게 경계할 필요는 없습니다! 파이썬 float" " 연산의 에러는 부동 소수점 하드웨어에서 상속된 것이고, 대부분 기계에서는 연산당 2\\*\\*53분의 1을 넘지 않는 규모입니다." " 이것은 대부분 작업에서 필요한 수준 이상입니다. 하지만, 십진 산술이 아니며 모든 float 연산에 새로운 반올림 에러가 발생할 " "수 있다는 점을 명심해야 합니다." #: ../../tutorial/floatingpoint.rst:163 msgid "" "While pathological cases do exist, for most casual use of floating-point " "arithmetic you'll see the result you expect in the end if you simply " "round the display of your final results to the number of decimal digits " "you expect. :func:`str` usually suffices, and for finer control see the " ":meth:`str.format` method's format specifiers in :ref:`formatstrings`." msgstr "" "병리학적 경우가 존재하지만, 무심히 부동 소수점 산술을 사용하는 대부분은, 단순히 최종 결과를 기대하는 자릿수로 반올림해서 표시하면" " 기대하는 결과를 보게 될 것입니다. 보통 :func:`str` 만으로도 충분하며, 더 세밀하게 제어하려면 " ":ref:`formatstrings` 에서 :meth:`str.format` 메서드의 포맷 지정자를 보세요." #: ../../tutorial/floatingpoint.rst:169 msgid "" "For use cases which require exact decimal representation, try using the " ":mod:`decimal` module which implements decimal arithmetic suitable for " "accounting applications and high-precision applications." msgstr "" "정확한 십진 표현이 필요한 사용 사례의 경우, 회계 응용 프로그램 및 고정밀 응용 프로그램에 적합한 십진 산술을 구현하는 " ":mod:`decimal` 모듈을 사용해보세요." #: ../../tutorial/floatingpoint.rst:173 msgid "" "Another form of exact arithmetic is supported by the :mod:`fractions` " "module which implements arithmetic based on rational numbers (so the " "numbers like 1/3 can be represented exactly)." msgstr "" "정확한 산술의 또 다른 형태는 유리수를 기반으로 산술을 구현하는 :mod:`fractions` 모듈에 의해 지원됩니다 (따라서 " "1/3과 같은 숫자는 정확하게 나타낼 수 있습니다)." #: ../../tutorial/floatingpoint.rst:177 msgid "" "If you are a heavy user of floating-point operations you should take a " "look at the NumPy package and many other packages for mathematical and " "statistical operations supplied by the SciPy project. See " "." msgstr "" "부동 소수점 연산을 많이 하는 사용자면 NumPy 패키지와 SciPy 프로젝트에서 제공하는 수학 및 통계 연산을 위한 다른 많은 " "패키지를 살펴봐야 합니다. 를 보세요." #: ../../tutorial/floatingpoint.rst:181 msgid "" "Python provides tools that may help on those rare occasions when you " "really *do* want to know the exact value of a float. The " ":meth:`float.as_integer_ratio` method expresses the value of a float as a" " fraction:" msgstr "" "파이썬은 여러분이 float의 정확한 값을 진짜로 *알아야 하는* 드문 경우를 지원할 수 있는 도구들을 제공합니다. " ":meth:`float.as_integer_ratio` 메서드는 float의 값을 분수로 표현합니다:" #: ../../tutorial/floatingpoint.rst:186 msgid "" ">>> x = 3.14159\n" ">>> x.as_integer_ratio()\n" "(3537115888337719, 1125899906842624)" msgstr "" ">>> x = 3.14159\n" ">>> x.as_integer_ratio()\n" "(3537115888337719, 1125899906842624)" #: ../../tutorial/floatingpoint.rst:192 msgid "" "Since the ratio is exact, it can be used to losslessly recreate the " "original value:" msgstr "비율은 정확한 값이기 때문에, 원래 값을 손실 없이 다시 만드는 데 사용할 수 있습니다:" #: ../../tutorial/floatingpoint.rst:195 msgid "" ">>> x == 3537115888337719 / 1125899906842624\n" "True" msgstr "" ">>> x == 3537115888337719 / 1125899906842624\n" "True" #: ../../tutorial/floatingpoint.rst:200 msgid "" "The :meth:`float.hex` method expresses a float in hexadecimal (base 16), " "again giving the exact value stored by your computer:" msgstr ":meth:`float.hex` 메서드는 float를 16진수(밑이 16이다)로 표현하는데, 컴퓨터에 저장된 정확한 값을 줍니다:" #: ../../tutorial/floatingpoint.rst:203 msgid "" ">>> x.hex()\n" "'0x1.921f9f01b866ep+1'" msgstr "" ">>> x.hex()\n" "'0x1.921f9f01b866ep+1'" #: ../../tutorial/floatingpoint.rst:208 msgid "" "This precise hexadecimal representation can be used to reconstruct the " "float value exactly:" msgstr "이 정확한 16진수 표현은 float 값을 정확하게 재구성하는 데 사용할 수 있습니다:" #: ../../tutorial/floatingpoint.rst:211 msgid "" ">>> x == float.fromhex('0x1.921f9f01b866ep+1')\n" "True" msgstr "" ">>> x == float.fromhex('0x1.921f9f01b866ep+1')\n" "True" #: ../../tutorial/floatingpoint.rst:216 msgid "" "Since the representation is exact, it is useful for reliably porting " "values across different versions of Python (platform independence) and " "exchanging data with other languages that support the same format (such " "as Java and C99)." msgstr "" "표현이 정확하므로, 파이썬의 다른 버전 에 걸쳐 값을 신뢰성 있게 이식하고 (플랫폼 독립성), 같은 형식을 지원하는 다른 " "언어(자바나 C99 같은)와 데이터를 교환하는 데 유용합니다." #: ../../tutorial/floatingpoint.rst:220 msgid "" "Another helpful tool is the :func:`sum` function which helps mitigate " "loss-of-precision during summation. It uses extended precision for " "intermediate rounding steps as values are added onto a running total. " "That can make a difference in overall accuracy so that the errors do not " "accumulate to the point where they affect the final total:" msgstr "" "또 다른 유용한 도구는 :func:`sum` 함수입니다. 이 함수는 합산하는 동안 정밀도 상실을 완화합니다. 값이 누계에 더해질 때" " 중간 반올림 단계에서 확장 정밀도를 사용합니다. 최종 합계에 영향을 주는 지점까지 에러가 누적되지 않아서 전체적인 정확도에 차이를" " 만들 수 있습니다:" #: ../../tutorial/floatingpoint.rst:226 msgid "" ">>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0\n" "False\n" ">>> sum([0.1] * 10) == 1.0\n" "True" msgstr "" ">>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0\n" "False\n" ">>> sum([0.1] * 10) == 1.0\n" "True" #: ../../tutorial/floatingpoint.rst:233 msgid "" "The :func:`math.fsum` goes further and tracks all of the \"lost digits\" " "as values are added onto a running total so that the result has only a " "single rounding. This is slower than :func:`sum` but will be more " "accurate in uncommon cases where large magnitude inputs mostly cancel " "each other out leaving a final sum near zero:" msgstr "" ":func:`math.fsum`\\은 더 나아가, 누계에 값이 더해질 때 모든 \"잃어버린 숫자들\"을 추적하여, 결과가 한 번만 " "반올림되도록 합니다. 이는 :func:`sum`\\보다 느리지만, 큰 값의 입력이 대부분 서로 상쇄되어, 최종 합이 0에 가까와지는" " 드문 경우에 더 정확합니다:" #: ../../tutorial/floatingpoint.rst:239 msgid "" ">>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16," "\n" "... -143401161400469.7, 266262841.31058735, -0.003244936839808227]" "\n" ">>> float(sum(map(Fraction, arr))) # Exact summation with single " "rounding\n" "8.042173697819788e-13\n" ">>> math.fsum(arr) # Single rounding\n" "8.042173697819788e-13\n" ">>> sum(arr) # Multiple roundings in extended " "precision\n" "8.042178034628478e-13\n" ">>> total = 0.0\n" ">>> for x in arr:\n" "... total += x # Multiple roundings in standard " "precision\n" "...\n" ">>> total # Straight addition has no correct " "digits!\n" "-0.0051575902860057365" msgstr "" ">>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16," "\n" "... -143401161400469.7, 266262841.31058735, -0.003244936839808227]" "\n" ">>> float(sum(map(Fraction, arr))) # 정확한 함계에 단일 반올림\n" "8.042173697819788e-13\n" ">>> math.fsum(arr) # 단일 반올림\n" "8.042173697819788e-13\n" ">>> sum(arr) # 확장 정밀도로 다중 반올림\n" "8.042178034628478e-13\n" ">>> total = 0.0\n" ">>> for x in arr:\n" "... total += x # 표준 정밀도로 다중 반올림\n" "...\n" ">>> total # 단순 합산은 올바른 결과를 주지 않습니다!\n" "-0.0051575902860057365" #: ../../tutorial/floatingpoint.rst:260 msgid "Representation Error" msgstr "표현 오류" #: ../../tutorial/floatingpoint.rst:262 msgid "" "This section explains the \"0.1\" example in detail, and shows how you " "can perform an exact analysis of cases like this yourself. Basic " "familiarity with binary floating-point representation is assumed." msgstr "" "이 섹션에서는 \"0.1\" 예제를 자세히 설명하고, 이러한 사례에 대한 정확한 분석을 여러분이 직접 수행하는 방법을 보여줍니다. " "이진 부동 소수점 표현에 대한 기본 지식이 있다고 가정합니다." #: ../../tutorial/floatingpoint.rst:266 msgid "" ":dfn:`Representation error` refers to the fact that some (most, actually)" " decimal fractions cannot be represented exactly as binary (base 2) " "fractions. This is the chief reason why Python (or Perl, C, C++, Java, " "Fortran, and many others) often won't display the exact decimal number " "you expect." msgstr "" ":dfn:`표현 오류 (Representation error)` 는 일부 (실제로는, 대부분의) 십진 소수가 이진(밑 2) 소수로 " "정확하게 표현될 수 없다는 사실을 나타냅니다. 이것이 파이썬(또는 펄, C, C++, 자바, 포트란 및 기타 여러 언어)이 종종 " "여러분이 기대하는 정확한 십진수를 표시하지 않는 주된 이유입니다." #: ../../tutorial/floatingpoint.rst:271 msgid "" "Why is that? 1/10 is not exactly representable as a binary fraction. " "Since at least 2000, almost all machines use IEEE 754 binary floating-" "point arithmetic, and almost all platforms map Python floats to IEEE 754 " "binary64 \"double precision\" values. IEEE 754 binary64 values contain " "53 bits of precision, so on input the computer strives to convert 0.1 to " "the closest fraction it can of the form *J*/2**\\ *N* where *J* is an " "integer containing exactly 53 bits. Rewriting ::" msgstr "" "왜 그럴까? 1/10은 이진 소수로 정확히 표현할 수 없습니다. 적어도 2000년 이후, 거의 모든 기계는 IEEE 754 이진 " "부동 소수점 산술을 사용하고, 거의 모든 플랫폼은 파이썬 float를 IEEE 754 binary64 \"배정밀도\"에 매핑합니다." " IEEE 754 binary64 값은 53비트의 정밀도가 포함되어 있어서, 입력 시 컴퓨터는 0.1을 *J*/2**\\ *N* " "형태의 가장 가까운 분수로 변환하려고 노력합니다. 여기서 *J* 는 정확히 53비트를 포함하는 정수입니다.::" #: ../../tutorial/floatingpoint.rst:280 msgid "1 / 10 ~= J / (2**N)" msgstr "1 / 10 ~= J / (2**N)" #: ../../tutorial/floatingpoint.rst:282 msgid "as ::" msgstr "를 ::" #: ../../tutorial/floatingpoint.rst:284 msgid "J ~= 2**N / 10" msgstr "J ~= 2**N / 10" #: ../../tutorial/floatingpoint.rst:286 msgid "" "and recalling that *J* has exactly 53 bits (is ``>= 2**52`` but ``< " "2**53``), the best value for *N* is 56:" msgstr "" "로 다시 쓰고, *J* 가 정확히 53 비트(``>= 2**52`` 이지만 ``< 2**53`` 입니다)임을 고려하면, *N* 의 " "최적값은 56입니다:" #: ../../tutorial/floatingpoint.rst:289 msgid "" ">>> 2**52 <= 2**56 // 10 < 2**53\n" "True" msgstr "" ">>> 2**52 <= 2**56 // 10 < 2**53\n" "True" #: ../../tutorial/floatingpoint.rst:294 msgid "" "That is, 56 is the only value for *N* that leaves *J* with exactly 53 " "bits. The best possible value for *J* is then that quotient rounded:" msgstr "" "즉, 56은 *J* 가 정확히 53비트가 되도록 만드는 *N* 의 유일한 값입니다. *J* 의 가능한 값 중 가장 좋은 것은 " "반올림한 몫입니다:" #: ../../tutorial/floatingpoint.rst:297 msgid "" ">>> q, r = divmod(2**56, 10)\n" ">>> r\n" "6" msgstr "" ">>> q, r = divmod(2**56, 10)\n" ">>> r\n" "6" #: ../../tutorial/floatingpoint.rst:303 msgid "" "Since the remainder is more than half of 10, the best approximation is " "obtained by rounding up:" msgstr "나머지가 10의 절반보다 크므로, 가장 가까운 근삿값은 올림 해서 얻어집니다:" #: ../../tutorial/floatingpoint.rst:306 msgid "" ">>> q+1\n" "7205759403792794" msgstr "" ">>> q+1\n" "7205759403792794" #: ../../tutorial/floatingpoint.rst:313 msgid "" "Therefore the best possible approximation to 1/10 in IEEE 754 double " "precision is::" msgstr "따라서 IEEE 754 배정밀도로 1/10 에 가장 가까운 근삿값은 다음과 같습니다::" #: ../../tutorial/floatingpoint.rst:316 msgid "7205759403792794 / 2 ** 56" msgstr "7205759403792794 / 2 ** 56" #: ../../tutorial/floatingpoint.rst:318 msgid "" "Dividing both the numerator and denominator by two reduces the fraction " "to::" msgstr "분자와 분모를 둘로 나누면 다음과 같이 약분됩니다::" #: ../../tutorial/floatingpoint.rst:320 msgid "3602879701896397 / 2 ** 55" msgstr "3602879701896397 / 2 ** 55" #: ../../tutorial/floatingpoint.rst:322 msgid "" "Note that since we rounded up, this is actually a little bit larger than " "1/10; if we had not rounded up, the quotient would have been a little bit" " smaller than 1/10. But in no case can it be *exactly* 1/10!" msgstr "" "올림을 했기 때문에, 이것은 실제로 1/10 보다 약간 크다는 것에 유의하세요; 내림을 했다면, 몫이 1/10 보다 약간 작아졌을 " "것입니다. 그러나 어떤 경우에도 *정확하게* 1/10일 수는 없습니다!" #: ../../tutorial/floatingpoint.rst:326 msgid "" "So the computer never \"sees\" 1/10: what it sees is the exact fraction " "given above, the best IEEE 754 double approximation it can get:" msgstr "" "따라서 컴퓨터는 결코 1/10을 \"보지\" 못합니다: 볼 수 있는 것은 위에서 주어진 정확한 분수, 얻을 수 있는 최선의 IEEE" " 754 배정밀도 근삿값입니다:" #: ../../tutorial/floatingpoint.rst:329 msgid "" ">>> 0.1 * 2 ** 55\n" "3602879701896397.0" msgstr "" ">>> 0.1 * 2 ** 55\n" "3602879701896397.0" #: ../../tutorial/floatingpoint.rst:334 msgid "" "If we multiply that fraction by 10\\*\\*55, we can see the value out to " "55 decimal digits:" msgstr "그 분수에 10\\*\\*55를 곱하면, 55개의 십진 숫자를 볼 수 있습니다:" #: ../../tutorial/floatingpoint.rst:337 msgid "" ">>> 3602879701896397 * 10 ** 55 // 2 ** 55\n" "1000000000000000055511151231257827021181583404541015625" msgstr "" ">>> 3602879701896397 * 10 ** 55 // 2 ** 55\n" "1000000000000000055511151231257827021181583404541015625" #: ../../tutorial/floatingpoint.rst:342 msgid "" "meaning that the exact number stored in the computer is equal to the " "decimal value 0.1000000000000000055511151231257827021181583404541015625. " "Instead of displaying the full decimal value, many languages (including " "older versions of Python), round the result to 17 significant digits:" msgstr "" "이는 컴퓨터에 저장된 정확한 숫자가 십진수 " "0.1000000000000000055511151231257827021181583404541015625와 같음을 의미합니다. 전체 " "십진법 값을 표시하는 대신, 많은 언어(이전 버전의 파이썬 포함)는 결과를 17개의 유효숫자로 반올림합니다:" #: ../../tutorial/floatingpoint.rst:347 msgid "" ">>> format(0.1, '.17f')\n" "'0.10000000000000001'" msgstr "" ">>> format(0.1, '.17f')\n" "'0.10000000000000001'" #: ../../tutorial/floatingpoint.rst:352 msgid "" "The :mod:`fractions` and :mod:`decimal` modules make these calculations " "easy:" msgstr ":mod:`fractions` 와 :mod:`decimal` 모듈은 이 계산을 쉽게 만듭니다:" #: ../../tutorial/floatingpoint.rst:355 msgid "" ">>> from decimal import Decimal\n" ">>> from fractions import Fraction\n" "\n" ">>> Fraction.from_float(0.1)\n" "Fraction(3602879701896397, 36028797018963968)\n" "\n" ">>> (0.1).as_integer_ratio()\n" "(3602879701896397, 36028797018963968)\n" "\n" ">>> Decimal.from_float(0.1)\n" "Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" "\n" ">>> format(Decimal.from_float(0.1), '.17')\n" "'0.10000000000000001'" msgstr "" ">>> from decimal import Decimal\n" ">>> from fractions import Fraction\n" "\n" ">>> Fraction.from_float(0.1)\n" "Fraction(3602879701896397, 36028797018963968)\n" "\n" ">>> (0.1).as_integer_ratio()\n" "(3602879701896397, 36028797018963968)\n" "\n" ">>> Decimal.from_float(0.1)\n" "Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" "\n" ">>> format(Decimal.from_float(0.1), '.17')\n" "'0.10000000000000001'"