@@ -32,6 +32,8 @@ msgid ""
32
32
"decimal floating-point arithmetic. It offers several advantages over the :"
33
33
"class:`float` datatype:"
34
34
msgstr ""
35
+ ":mod:`decimal` 模組提供對快速正確捨入的十進位浮點運算的支援。相較於 :class:"
36
+ "`float` 資料型別,它提供了幾個優勢:"
35
37
36
38
#: ../../library/decimal.rst:37
37
39
msgid ""
@@ -41,6 +43,9 @@ msgid ""
41
43
"people learn at school.\" -- excerpt from the decimal arithmetic "
42
44
"specification."
43
45
msgstr ""
46
+ "Decimal「基於一個以人為設計考量的浮點模型,並且必然有一個至關重要的指導原則 "
47
+ "—— 電腦必須提供與人們在學校學習的算術運算方式相同的算術運算。」—— 摘自十進位"
48
+ "算術規範。"
44
49
45
50
#: ../../library/decimal.rst:42
46
51
msgid ""
@@ -49,6 +54,9 @@ msgid ""
49
54
"point. End users typically would not expect ``1.1 + 2.2`` to display as "
50
55
"``3.3000000000000003`` as it does with binary floating point."
51
56
msgstr ""
57
+ "Decimal 數字可以被精確表示。相對地,像 ``1.1`` 和 ``2.2`` 這樣的數字在二進位"
58
+ "浮點數中沒有精確的表示方式。終端使用者通常不會期望 ``1.1 + 2.2`` 顯示為 "
59
+ "``3.3000000000000003``,但這正是二進位浮點數的表現。"
52
60
53
61
#: ../../library/decimal.rst:47
54
62
msgid ""
@@ -59,6 +67,10 @@ msgid ""
59
67
"accumulate. For this reason, decimal is preferred in accounting applications "
60
68
"which have strict equality invariants."
61
69
msgstr ""
70
+ "精確性延續到算術運算中。在十進位浮點數中,``0.1 + 0.1 + 0.1 - 0.3`` 完全"
71
+ "等於零。在二進位浮點數中,結果是 ``5.5511151231257827e-017``。雖然接近零,"
72
+ "但這些差異會妨礙可靠的相等性測試,並且差異可能累積。因此,在具有嚴格相等"
73
+ "不變量的會計應用程式中,decimal 是首選。"
62
74
63
75
#: ../../library/decimal.rst:54
64
76
msgid ""
@@ -69,13 +81,19 @@ msgid ""
69
81
"multiplicands. For instance, ``1.3 * 1.2`` gives ``1.56`` while ``1.30 * "
70
82
"1.20`` gives ``1.5600``."
71
83
msgstr ""
84
+ "decimal 模組納入了有效位數的概念,使得 ``1.30 + 1.20`` 等於 ``2.50``。尾隨"
85
+ "零被保留以表示有效性。這是金融應用程式的慣例表示法。對於乘法,「課本」方法"
86
+ "使用被乘數中的所有數字。例如,``1.3 * 1.2`` 得到 ``1.56``,而 ``1.30 * "
87
+ "1.20`` 得到 ``1.5600``。"
72
88
73
89
#: ../../library/decimal.rst:61
74
90
msgid ""
75
91
"Unlike hardware based binary floating point, the decimal module has a user "
76
92
"alterable precision (defaulting to 28 places) which can be as large as "
77
93
"needed for a given problem:"
78
94
msgstr ""
95
+ "與基於硬體的二進位浮點數不同,decimal 模組具有使用者可變的精度(預設為 28 位),"
96
+ "可以根據給定問題的需要設定得足夠大:"
79
97
80
98
#: ../../library/decimal.rst:73
81
99
msgid ""
@@ -86,6 +104,10 @@ msgid ""
86
104
"signal handling. This includes an option to enforce exact arithmetic by "
87
105
"using exceptions to block any inexact operations."
88
106
msgstr ""
107
+ "二進位和十進位浮點數都是根據已發布的標準實作的。雖然內建的 float 型別只"
108
+ "暴露其功能的一小部分,但 decimal 模組暴露了標準的所有必要部分。必要時,"
109
+ "程式設計師對捨入和訊號處理有完全的控制權。這包括透過使用例外來阻止任何"
110
+ "不精確運算以強制執行精確算術的選項。"
89
111
90
112
#: ../../library/decimal.rst:80
91
113
msgid ""
@@ -94,12 +116,15 @@ msgid ""
94
116
"rounded floating-point arithmetic.\" -- excerpt from the decimal arithmetic "
95
117
"specification."
96
118
msgstr ""
119
+ "decimal 模組被設計為支援「無偏見地支援精確的未捨入十進位算術(有時稱為定點"
120
+ "算術)和捨入浮點算術。」—— 摘自十進位算術規範。"
97
121
98
122
#: ../../library/decimal.rst:85
99
123
msgid ""
100
124
"The module design is centered around three concepts: the decimal number, "
101
125
"the context for arithmetic, and signals."
102
126
msgstr ""
127
+ "模組設計圍繞三個概念:decimal 數字、算術情境和訊號。"
103
128
104
129
#: ../../library/decimal.rst:88
105
130
msgid ""
@@ -109,6 +134,9 @@ msgid ""
109
134
"``-Infinity``, and ``NaN``. The standard also differentiates ``-0`` from "
110
135
"``+0``."
111
136
msgstr ""
137
+ "decimal 數字是不可變的。它有符號、係數數字和指數。為了保持有效性,係數數字"
138
+ "不會截斷尾隨零。Decimal 也包含特殊值,如 ``Infinity``、``-Infinity`` 和 "
139
+ "``NaN``。標準也區分 ``-0`` 和 ``+0``。"
112
140
113
141
#: ../../library/decimal.rst:94
114
142
msgid ""
@@ -119,6 +147,11 @@ msgid ""
119
147
"`ROUND_FLOOR`, :const:`ROUND_HALF_DOWN`, :const:`ROUND_HALF_EVEN`, :const:"
120
148
"`ROUND_HALF_UP`, :const:`ROUND_UP`, and :const:`ROUND_05UP`."
121
149
msgstr ""
150
+ "算術情境是一個指定精度、捨入規則、指數限制、指示運算結果的旗標,以及決定"
151
+ "訊號是否被視為例外的陷阱啟用器的環境。捨入選項包括 :const:`ROUND_CEILING`、"
152
+ ":const:`ROUND_DOWN`、:const:`ROUND_FLOOR`、:const:`ROUND_HALF_DOWN`、:const:"
153
+ "`ROUND_HALF_EVEN`、:const:`ROUND_HALF_UP`、:const:`ROUND_UP` 和 :const:"
154
+ "`ROUND_05UP`。"
122
155
123
156
#: ../../library/decimal.rst:101
124
157
msgid ""
@@ -130,6 +163,11 @@ msgid ""
130
163
"`Subnormal`, :const:`Overflow`, :const:`Underflow` and :const:"
131
164
"`FloatOperation`."
132
165
msgstr ""
166
+ "訊號是在計算過程中產生的例外條件群組。根據應用程式的需求,訊號可能被忽略、"
167
+ "視為資訊性質,或被視為例外。decimal 模組中的訊號包括::const:`Clamped`、"
168
+ ":const:`InvalidOperation`、:const:`DivisionByZero`、:const:`Inexact`、:const:"
169
+ "`Rounded`、:const:`Subnormal`、:const:`Overflow`、:const:`Underflow` 和 "
170
+ ":const:`FloatOperation`。"
133
171
134
172
#: ../../library/decimal.rst:108
135
173
msgid ""
@@ -138,12 +176,17 @@ msgid ""
138
176
"one, an exception is raised. Flags are sticky, so the user needs to reset "
139
177
"them before monitoring a calculation."
140
178
msgstr ""
179
+ "每個訊號都有一個旗標和一個陷阱啟用器。當遇到訊號時,其旗標被設定為一,然後,"
180
+ "如果陷阱啟用器被設定為一,就會引發例外。旗標是黏性的,因此使用者需要在監控"
181
+ "計算之前重設它們。"
141
182
142
183
#: ../../library/decimal.rst:116
143
184
msgid ""
144
185
"IBM's General Decimal Arithmetic Specification, `The General Decimal "
145
186
"Arithmetic Specification <https://speleotrove.com/decimal/decarith.html>`_."
146
187
msgstr ""
188
+ "IBM 的一般十進位算術規範,`一般十進位算術規範 "
189
+ "<https://speleotrove.com/decimal/decarith.html>`_。"
147
190
148
191
#: ../../library/decimal.rst:125
149
192
msgid "Quick-start tutorial"
@@ -414,6 +457,8 @@ msgid ""
414
457
"`ExtendedContext`. The former is especially useful for debugging because "
415
458
"many of the traps are enabled:"
416
459
msgstr ""
460
+ "根據標準,:mod:`decimal` 模組提供兩個現成可用的標準情境,:const:`BasicContext` "
461
+ "和 :const:`ExtendedContext`。前者特別適用於除錯,因為許多陷阱都已啟用:"
417
462
418
463
#: ../../library/decimal.rst:275
419
464
msgid ""
@@ -466,6 +511,9 @@ msgid ""
466
511
"cleared, so it is best to clear the flags before each set of monitored "
467
512
"computations by using the :meth:`~Context.clear_flags` method. ::"
468
513
msgstr ""
514
+ "情境也有訊號旗標用於監控計算過程中遇到的例外條件。旗標會保持設定狀態直到"
515
+ "明確清除,因此最好在每組受監控的計算之前使用 :meth:`~Context.clear_flags` "
516
+ "方法清除旗標: ::"
469
517
470
518
#: ../../library/decimal.rst:304
471
519
msgid ""
@@ -491,12 +539,15 @@ msgid ""
491
539
"(digits beyond the context precision were thrown away) and that the result "
492
540
"is inexact (some of the discarded digits were non-zero)."
493
541
msgstr ""
542
+ "*flags* 條目顯示對 pi 的有理逼近已被捨入(超出情境精度的數字被丟棄),並且"
543
+ "結果是不精確的(一些被丟棄的數字非零)。"
494
544
495
545
#: ../../library/decimal.rst:316
496
546
msgid ""
497
547
"Individual traps are set using the dictionary in the :attr:`~Context.traps` "
498
548
"attribute of a context:"
499
549
msgstr ""
550
+ "個別陷阱使用情境的 :attr:`~Context.traps` 屬性中的字典設定:"
500
551
501
552
#: ../../library/decimal.rst:319
502
553
msgid ""
@@ -528,6 +579,9 @@ msgid ""
528
579
"the bulk of the program manipulates the data no differently than with other "
529
580
"Python numeric types."
530
581
msgstr ""
582
+ "大多數程式只在程式開始時調整一次目前情境。在許多應用程式中,資料在迴圈內"
583
+ "透過單次轉換轉換為 :class:`Decimal`。設定情境並建立 decimal 後,程式的大部分"
584
+ "操作資料的方式與其他 Python 數值型別沒有什麼不同。"
531
585
532
586
#: ../../library/decimal.rst:343
533
587
msgid "Decimal objects"
@@ -745,12 +799,14 @@ msgid ""
745
799
"Mixed-type comparisons between :class:`Decimal` instances and other numeric "
746
800
"types are now fully supported."
747
801
msgstr ""
802
+ ":class:`Decimal` 實例與其他數值型別之間的混合型別比較現在完全支援。"
748
803
749
804
#: ../../library/decimal.rst:450
750
805
msgid ""
751
806
"In addition to the standard numeric properties, decimal floating-point "
752
807
"objects also have a number of specialized methods:"
753
808
msgstr ""
809
+ "除了標準數值屬性外,decimal 浮點數物件也有許多專門的方法:"
754
810
755
811
#: ../../library/decimal.rst:456
756
812
msgid ""
@@ -759,6 +815,8 @@ msgid ""
759
815
"returns seven. Used for determining the position of the most significant "
760
816
"digit with respect to the decimal point."
761
817
msgstr ""
818
+ "在移出係數的最右邊數字直到只剩下前導數字後,回傳調整後的指數:"
819
+ "``Decimal('321e+5').adjusted()`` 回傳七。用於確定最高有效數字相對於小數點的位置。"
762
820
763
821
#: ../../library/decimal.rst:463
764
822
msgid ""
0 commit comments