diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index 0b3f1c4f6c..65ddd82474 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -1,14 +1,17 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2018, Python Software Foundation +# Copyright (C) 2001-2021, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: +# yichung279, 2018 +# cypevan, 2018 +# Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.7\n" +"Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-26 18:54+0800\n" -"PO-Revision-Date: 2018-11-20 14:26+0800\n" +"PO-Revision-Date: 2021-06-28 18:50+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -17,7 +20,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 2.1.1\n" +"X-Generator: Poedit 2.4.3\n" #: ../../tutorial/floatingpoint.rst:9 msgid "Floating Point Arithmetic: Issues and Limitations" @@ -28,7 +31,8 @@ msgid "" "Floating-point numbers are represented in computer hardware as base 2 " "(binary) fractions. For example, the decimal fraction ::" msgstr "" -"在計算機架構中,浮點數透過二進位小數表示。例如說,在十進位小數中:\n" +"在計算機架構中,浮點數 (floating-point number) 是以基數為 2(二進位)的小數表" +"示。例如說,在十進位小數中:\n" "\n" "::" @@ -36,7 +40,7 @@ msgstr "" msgid "" "has value 1/10 + 2/100 + 5/1000, and in the same way the binary fraction ::" msgstr "" -"可被分為 1/10 + 2/100 + 5/1000,同樣的道理,二進位小數 :\n" +"可被分為 1/10 + 2/100 + 5/1000,同樣的道理,二進位小數:\n" "\n" "::" @@ -56,15 +60,15 @@ msgid "" "point numbers you enter are only approximated by the binary floating-point " "numbers actually stored in the machine." msgstr "" -"不幸的是,大多數十進位小數無法精準地以二進位小數表示。一般的結果為,您輸入的" -"十進位浮點數由實際存在計算機中的二進位浮點數近似。" +"不幸的是,大多數十進位小數無法精準地以二進位小數表示。一般的結果為,你輸入的" +"十進位浮點數只能由實際儲存在計算機中的二進位浮點數近似。" #: ../../tutorial/floatingpoint.rst:32 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 "" -"在十進位中,這個問題更容易被理解。以分數 1/3 為例,您可以將其近似為十進位小" +"在十進位中,這個問題更容易被理解。以分數 1/3 為例,你可以將其近似為十進位小" "數:\n" "\n" "::" @@ -92,7 +96,7 @@ msgid "" "base 2, 1/10 is the infinitely repeating fraction ::" msgstr "" "同樣的道理,不論你願意以多少位數表示二進位小數,十進位小數 0.1 都無法被二進位" -"小數精準地表達。在二進位小數中, 1/10 會是一個無限循環小數:\n" +"小數精準地表達。在二進位小數中,1/10 會是一個無限循環小數:\n" "\n" "::" @@ -105,9 +109,9 @@ msgid "" "fraction is ``3602879701896397 / 2 ** 55`` which is close to but not exactly " "equal to the true value of 1/10." msgstr "" -"只要您停在任何有限的位數,您就只會得到近似值。而現在大多數的計算機中,浮點數" -"是透過二進位分數近似的,其中分子從最高有效位元使開始用 53 個位元表示,分母則" -"是以二為底的指數。在 1/10 的例子中,二進位分數為 ``3602879701896397 / 2 ** " +"只要你停在任何有限的位數,你就只會得到近似值。而現在大多數的計算機中,浮點數" +"是透過二進位分數近似的,其中分子是從最高有效位元開始,用 53 個位元表示,分母" +"則是以二為底的指數。在 1/10 的例子中,二進位分數為 ``3602879701896397 / 2 ** " "55``,而這樣的表示十分地接近,但不完全等同於 1/10 的真正數值。" #: ../../tutorial/floatingpoint.rst:62 @@ -119,9 +123,9 @@ msgid "" "stored for 0.1, it would have to display ::" msgstr "" "由於數值顯示的方式,很多使用者並沒有發現數值是個近似值。Python 只會印出一個十" -"進位近似值,其近似了儲存在計算機中的二進位近似值的十進位數值。在大多數的計算" -"機中,如果 Python 真的會印出完整的十進位數值,其表示儲存在計算機中的 0.1 的二" -"進位近似值,它將顯示為:\n" +"進位近似值,其近似了儲存在計算機中的二進位近似值的真正十進位數值。在大多數的" +"計算機中,如果 Python 真的會印出完整的十進位數值,其表示儲存在計算機中的 0.1 " +"的二進位近似值,它將顯示為:\n" "\n" "::" @@ -153,11 +157,11 @@ msgid "" "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``。" +"``3602879701896397 / 2 ** 55`` 近似。由於這三個十進位數值共用同一個近似值,任" +"何一個數值都可以被顯示,同時保持 ``eval(repr(x)) == x``。" #: ../../tutorial/floatingpoint.rst:88 msgid "" @@ -168,7 +172,7 @@ msgid "" msgstr "" "歷史上,Python 的提示字元 (prompt) 與內建的 :func:`repr` 函式會選擇上段說明中" "有 17 個有效位元的數:``0.10000000000000001``。從 Python 3.1 版開始," -"Python(在大部分的系統上)可以選擇其中最短的數並簡單地顯示為 ``0.1``。" +"Python(在大部分的系統上)現在能選擇其中最短的數並簡單地顯示為 ``0.1``。" #: ../../tutorial/floatingpoint.rst:93 msgid "" @@ -178,16 +182,17 @@ msgid "" "arithmetic (although some languages may not *display* the difference by " "default, or in all output modes)." msgstr "" -"注意,這是二進位浮點數理所當然的特性,並不是 Python 的錯誤 (bug),更不是您程" -"式碼的錯誤。只要有程式語言支持硬體的浮點數運算,您將會看到同樣的事情出現在其" -"中(雖然某些程式語言預設不\\ *顯示*\\ 差異,或者預設全部輸出)。" +"注意,這是二進位浮點數理所當然的特性,並不是 Python 的錯誤 (bug),更不是你程" +"式碼的錯誤。只要程式語言有支援硬體的浮點數運算,你將會看到同樣的事情出現在其" +"中(雖然有些程式語言預設不會\\ *顯示*\\ 該差異,有些甚至是在所有的輸出模式中" +"都不會顯示。)" #: ../../tutorial/floatingpoint.rst:99 msgid "" "For more pleasant output, you may wish to use string formatting to produce a " "limited number of significant digits::" msgstr "" -"為求更優雅的輸出,您可能想要使用字串的格式化 (string formatting) 產生限定的有" +"為求更優雅的輸出,你可能想要使用字串的格式化 (string formatting) 產生限定的有" "效位數:\n" "\n" "::" @@ -240,8 +245,8 @@ msgid "" "www.lahey.com/float.htm>`_ for a more complete account of other common " "surprises." msgstr "" -"二進位浮點數架構擁有很多這樣的驚喜。底下的「表示法錯誤」章節,詳細的解釋了" -"「0.1」的問題。如果想要其他常見驚喜更完整的描述,可以參考 `The Perils of " +"二進位浮點數架構擁有很多這樣的驚喜。底下的「表示法誤差」章節,詳細地解釋了" +"「0.1」的問題。如果想要其他常見驚喜的更完整描述,可以參考 `The Perils of " "Floating Point(浮點數的風險) `_。" #: ../../tutorial/floatingpoint.rst:139 @@ -254,6 +259,11 @@ msgid "" "decimal arithmetic and that every float operation can suffer a new rounding " "error." msgstr "" +"如同上文的末段所述,「這個問題並沒有簡單的答案。」不過,也不必對浮點過度擔" +"心!Python 的 float(浮點數)運算中的誤差,是從浮點硬體繼承而來,而在大多數的" +"計算機上,每次運算的誤差範圍不會大於 2\\*\\*53 分之 1。這對大多數的任務來說已" +"經相當足夠,但你需要記住,它並非十進位運算,且每一次 float 運算都可能會承受新" +"的捨入誤差。" #: ../../tutorial/floatingpoint.rst:146 msgid "" @@ -263,6 +273,10 @@ msgid "" "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` method(方法)的格式規範。" #: ../../tutorial/floatingpoint.rst:152 msgid "" @@ -270,6 +284,8 @@ msgid "" "`decimal` module which implements decimal arithmetic suitable for accounting " "applications and high-precision applications." msgstr "" +"對於需要精準十進位表示法的用例,可以試著用 :mod:`decimal` 模組,它可實作適用" +"於會計應用程式與高精確度應用程式的十進位運算。" #: ../../tutorial/floatingpoint.rst:156 msgid "" @@ -277,14 +293,18 @@ msgid "" "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:160 msgid "" "If you are a heavy user of floating point operations you should take a look " -"at the Numerical Python package and many other packages for mathematical and " +"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:164 msgid "" @@ -292,24 +312,39 @@ msgid "" "*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 的精準值,Python 提供的工具可" +"協助達成。\\ :meth:`float.as_integer_ratio` method 可將一個 float 的值表示為" +"分數:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:173 msgid "" "Since the ratio is exact, it can be used to losslessly recreate the original " "value::" msgstr "" +"由於該比率是精準的,它可無損地再現該原始值:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:179 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` method 以十六進位(基數為 16)表示 float,一樣可以給出你的" +"電腦所儲存的精準值:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:185 msgid "" "This precise hexadecimal representation can be used to reconstruct the float " "value exactly::" msgstr "" +"這種精確的十六進位表示法可用於精準地重建 float 值:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:191 msgid "" @@ -318,6 +353,8 @@ msgid "" "data with other languages that support the same format (such as Java and " "C99)." msgstr "" +"由於該表示法是精準的,因此適用於在不同版本的 Python 之間可靠地傳送數值(獨立" +"於系統平台),並與支援相同格式的其他語言(如 JAVA 和 C99)交換資料。" #: ../../tutorial/floatingpoint.rst:195 msgid "" @@ -327,10 +364,14 @@ msgid "" "so that the errors do not accumulate to the point where they affect the " "final total:" msgstr "" +"另一個有用的工具是 :func:`math.fsum` 函式,能在計算總和時幫忙減少精確度的損" +"失。當數值被加到運行中的總計值時,它會追蹤「失去的位數 (lost digits)」。這可" +"以明顯改善總體準確度 (overall accuracy),使得誤差不至於累積到影響最終總計值的" +"程度:" #: ../../tutorial/floatingpoint.rst:209 msgid "Representation Error" -msgstr "" +msgstr "表示法誤差 (Representation Error)" #: ../../tutorial/floatingpoint.rst:211 msgid "" @@ -338,6 +379,8 @@ msgid "" "perform an exact analysis of cases like this yourself. Basic familiarity " "with binary floating-point representation is assumed." msgstr "" +"本節將會詳細解釋「0.1」的例子,並說明你自己要如何對類似案例執行精準的分析。 " +"以下假設你對二進位浮點表示法已有基本程度的熟悉。" #: ../../tutorial/floatingpoint.rst:215 msgid "" @@ -347,6 +390,10 @@ msgid "" "Fortran, and many others) often won't display the exact decimal number you " "expect." msgstr "" +":dfn:`Representation error`\\ (表示法誤差)是指在真實情況中,有些(實際上是" +"大多數)十進位小數並不能精準地以二進位(基數為 2)小數表示。這是 Python(或 " +"Perl、C、C++、JAVA、Fortran 和其他許多)通常不會顯示你期望的精準十進位數字的" +"主要原因。" #: ../../tutorial/floatingpoint.rst:220 msgid "" @@ -357,39 +404,67 @@ msgid "" "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 年 11 月)幾" +"乎所有的計算機皆使用 IEEE-754 浮點數運算標準,並且幾乎所有的平台都以 " +"IEEE-754 標準中的「雙精度 (double precision)」來繪製 Python 的 float。754 " +"double 包含 53 位元的精度,所以在輸入時,電腦會努力把 0.1 轉換到最接近的分" +"數,以 *J*/2**\\ *N* 的形式表示,此處 *J* 是一個正好包含 53 位元的整數。可以" +"將:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:229 msgid "as ::" msgstr "" +"重寫為:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:233 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:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:239 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 "" +"意即,要使 *J* 正好有 53 位元,則 56 會是 *N* 的唯一值。而 *J* 最有可能的數值" +"就是經過捨入後的該商數:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:246 msgid "" "Since the remainder is more than half of 10, the best approximation is " "obtained by rounding up::" msgstr "" +"由於餘數超過 10 的一半,所以最佳的近似值是透過進位而得:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:252 msgid "" "Therefore the best possible approximation to 1/10 in 754 double precision " "is::" msgstr "" +"所以,在 754 雙精度下,1/10 的最佳近似值是:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:256 msgid "" "Dividing both the numerator and denominator by two reduces the fraction to::" msgstr "" +"將分子和分母同除以二,會約分為:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:260 msgid "" @@ -397,18 +472,27 @@ msgid "" "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:264 msgid "" "So the computer never \"sees\" 1/10: what it sees is the exact fraction " "given above, the best 754 double approximation it can get::" msgstr "" +"所以電腦從來沒有「看到」1/10:它看到的是上述的精準分數,也就是它能得到的 754 " +"double 最佳近似值:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:270 msgid "" "If we multiply that fraction by 10\\*\\*55, we can see the value out to 55 " "decimal digits::" msgstr "" +"如果將該分數乘以 10\\*\\*55,則可以看到該值以 55 個十進位數字顯示:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:276 msgid "" @@ -417,9 +501,17 @@ msgid "" "displaying the full decimal value, many languages (including older versions " "of Python), round the result to 17 significant digits::" msgstr "" +"這表示儲存在電腦中的精準數值等於十進位值 " +"0.1000000000000000055511151231257827021181583404541015625。與其顯示完整的十進" +"位數值,許多語言(包括 Python 的舊版本)選擇將結果捨入至 17 個有效位數:\n" +"\n" +"::" #: ../../tutorial/floatingpoint.rst:284 msgid "" "The :mod:`fractions` and :mod:`decimal` modules make these calculations " "easy::" msgstr "" +":mod:`fractions` 與 :mod:`decimal` 模組能使這些計算變得容易:\n" +"\n" +"::"