Commits

Tetsuya Morimoto committed c3db4e3

translated decimal into Japanese

  • Participants
  • Parent commits 976ab7f

Comments (0)

Files changed (5)

PyMOTW/decimal/decimal_create.py

 print fmt.format('Input', 'Output')
 print fmt.format('-' * 20, '-' * 20)
 
-# Integer
+# 整数
 print fmt.format(5, decimal.Decimal(5))
 
-# String
+# 文字列
 print fmt.format('3.14', decimal.Decimal('3.14'))
 
-# Float
+# 浮動小数
 print fmt.format(repr(0.1), decimal.Decimal(str(0.1)))

PyMOTW/decimal/decimal_instance_context.py

 
 import decimal
 
-# Set up a context with limited precision
+# コンテキストを制限された精度で設定する
 c = decimal.getcontext().copy()
 c.prec = 3
 
-# Create our constant
+# 定数を作成
 pi = c.create_decimal('3.1415')
 
-# The constant value is rounded off
+# 定数の値は丸められる
 print 'PI:', pi
 
-# The result of using the constant uses the global context
-print 'RESULT:', decimal.Decimal('2.01') * pi
+# 定数を使用した結果はグローバルコンテキストを使用する
+print 'RESULT:', decimal.Decimal('2.01') * pi

PyMOTW/decimal/decimal_special.py

     print decimal.Decimal(value), decimal.Decimal('-' + value)
 print
 
-# Math with infinity
+# 無限大
 print 'Infinity + 1:', (decimal.Decimal('Infinity') + 1)
 print '-Infinity + 1:', (decimal.Decimal('-Infinity') + 1)
 
-# Print comparing NaN
+# NaN との比較結果を表示する
 print decimal.Decimal('NaN') == decimal.Decimal('Infinity')
-print decimal.Decimal('NaN') != decimal.Decimal(1)
+print decimal.Decimal('NaN') != decimal.Decimal(1)

PyMOTW/decimal/decimal_tuple.py

 
 import decimal
 
-# Tuple
+# タプル
 t = (1, (1, 1), -2)
 print 'Input  :', t
 print 'Decimal:', decimal.Decimal(t)

PyMOTW/decimal/index.rst

-========================================
-decimal -- Fixed and floating point math
-========================================
+..
+    ========================================
+    decimal -- Fixed and floating point math
+    ========================================
+
+=====================================
+decimal -- 固定小数点数と浮動小数点数
+=====================================
+
+..
+    :synopsis: Fixed and floating point math
 
 .. module:: decimal
-    :synopsis: Fixed and floating point math
+    :synopsis: 固定小数点数と浮動小数点数
 
-:Purpose: Decimal arithmetic using fixed and floating point numbers
-:Available In: 2.4 and later
+..
+    :Purpose: Decimal arithmetic using fixed and floating point numbers
+    :Available In: 2.4 and later
 
-The :mod:`decimal` module implements fixed and floating point
-arithmetic using the model familiar to most people, rather than the
-IEEE floating point version implemented by most computer hardware.  A
-Decimal instance can represent any number exactly, round up or down,
-and apply a limit to the number of significant digits.
+:目的: 固定小数点数と浮動小数点数を扱う10進数の計算
+:利用できるバージョン: 2.4 以上
+
+..
+    The :mod:`decimal` module implements fixed and floating point
+    arithmetic using the model familiar to most people, rather than the
+    IEEE floating point version implemented by most computer hardware.  A
+    Decimal instance can represent any number exactly, round up or down,
+    and apply a limit to the number of significant digits.
+
+:mod:`decimal` モジュールは、コンピュータのハードウェアが実装した IEEE の浮動小数点数より、人間にとって分かりやすいモデルの固定小数点数と浮動小数点数を実装します。Decimal インスタンスは、任意の数を正確に表したり、端数の切り上げや切り下げ、有効桁数の制限を設けます。
 
 Decimal
 =======
 
-Decimal values are represented as instances of the :class:`Decimal`
-class.  The constructor takes as argument an integer, or a string.
-Floating point numbers must be converted to a string before being used
-to create a :class:`Decimal`, letting the caller explicitly deal with
-the number of digits for values that cannot be expressed exactly using
-hardware floating point representations.
+..
+    Decimal values are represented as instances of the :class:`Decimal`
+    class.  The constructor takes as argument an integer, or a string.
+    Floating point numbers must be converted to a string before being used
+    to create a :class:`Decimal`, letting the caller explicitly deal with
+    the number of digits for values that cannot be expressed exactly using
+    hardware floating point representations.
+
+Decimal の値は :class:`Decimal` クラスのインスタンスとして表されます。コンストラクタの引数は整数か文字列を受け取ります。 :class:`Decimal` で浮動小数点数を表すには、その引数を文字列に変換しなければなりません。そして :class:`Decimal` は、ハードウェアの浮動小数点数では正確に表せない桁の値を呼び出し側で明示的に指定できます。
 
 .. include:: decimal_create.py
     :literal:
     :start-after: #end_pymotw_header
 
-Notice that the floating point value of ``0.1`` is not represented as
-an exact value, so the representation as a float is different from the
-Decimal value.
+..
+    Notice that the floating point value of ``0.1`` is not represented as
+    an exact value, so the representation as a float is different from the
+    Decimal value.
+
+``0.1`` という値の浮動小数点数は、厳密な値の表現ではないので、その浮動小数表現は Decimal の値とは違うことに注意してください。
 
 .. {{{cog
 .. cog.out(run_script(cog.inFile, 'decimal_create.py'))
 .. }}}
 .. {{{end}}}
 
-Less conveniently, Decimals can also be created from tuples containing
-a sign flag (``0`` for positive, ``1`` for negative), a tuple of
-digits, and an integer exponent.
+..
+    Less conveniently, Decimals can also be created from tuples containing
+    a sign flag (``0`` for positive, ``1`` for negative), a tuple of
+    digits, and an integer exponent.
+
+あまり使い勝手が良くないですが、Decimal は符号のフラグ (``0`` は正, ``1`` は負)、それぞれの桁の値を表すタプル、整数の指数の3つの値をもつタプルからも作成されます。
 
 .. include:: decimal_tuple.py
     :literal:
 .. }}}
 .. {{{end}}}
 
+..
+    Arithmetic
+    ==========
 
-Arithmetic
-==========
+計算
+====
 
-Decimal overloads the simple arithmetic operators so once you have a
-value you can manipulate it in much the same way as the built-in
-numeric types.
+..
+    Decimal overloads the simple arithmetic operators so once you have a
+    value you can manipulate it in much the same way as the built-in
+    numeric types.
+
+Decimal は、単純な算術演算子をオーバーロードするので、ある値が与えられたときに組み込みの数値型とほぼ同じようにその値を計算します。
 
 .. include:: decimal_operators.py
     :literal:
     :start-after: #end_pymotw_header
 
-Decimal operators also accept integer arguments, but floating point
-values must be converted to Decimal instances.
+..
+    Decimal operators also accept integer arguments, but floating point
+    values must be converted to Decimal instances.
+
+また Decimal の演算子は整数を受け取って計算できますが、浮動小数の場合は Decimal インスタンスに変換する必要があります。
 
 .. {{{cog
 .. cog.out(run_script(cog.inFile, 'decimal_operators.py'))
 .. }}}
 .. {{{end}}}
 
+..
+    Logarithms
+    ==========
 
-Logarithms
-==========
+対数
+====
 
-Beyond basic arithmetic, Decimal includes methods to find the base 10
-and natural logarithms.
+..
+    Beyond basic arithmetic, Decimal includes methods to find the base 10
+    and natural logarithms.
+
+基本的な計算に加えて、自然対数や10を底とする常用対数を調べるメソッドも提供します。
 
 .. include:: decimal_log.py
     :literal:
 .. }}}
 .. {{{end}}}
 
+..
+    Special Values
+    ==============
 
+特殊な値
+========
 
-Special Values
-==============
+..
+    In addition to the expected numerical values, :class:`Decimal` can
+    represent several special values, including positive and negative
+    values for infinity, "not a number", and zero.
 
-In addition to the expected numerical values, :class:`Decimal` can
-represent several special values, including positive and negative
-values for infinity, "not a number", and zero.
+期待される数値表現に加えて、 :class:`Decimal` は、正負の無限大、"数値ではない"、ゼロを含む特殊な値を表現できます。
 
 .. include:: decimal_special.py
     :literal:
     :start-after: #end_pymotw_header
 
-Adding to infinite values returns another infinite value.  Comparing
-for equality with NaN always returns False and comparing for
-inequality always returns true.  Comparing for sort order against NaN
-is undefined and results in an error.
+..
+    Adding to infinite values returns another infinite value.  Comparing
+    for equality with NaN always returns False and comparing for
+    inequality always returns true.  Comparing for sort order against NaN
+    is undefined and results in an error.
+
+無限大に値を加算すると、別の無限大の値を返します。NaN と等式で比較すると必ず False を返し、不等式で比較すると必ず True を返します。NaN に対してソートの比較を行うと、未定義のエラーが発生します。
 
 .. {{{cog
 .. cog.out(run_script(cog.inFile, 'decimal_special.py'))
 .. }}}
 .. {{{end}}}
 
+..
+    Context
+    =======
 
-Context
-=======
+コンテキスト
+============
 
-So far all of the examples have used the default behaviors of the
-decimal module. It is possible to override settings such as the
-precision maintained, how rounding is performed, error handling,
-etc. All of these settings are maintained via a *context*.  Contexts
-can be applied for all Decimal instances in a thread or locally within
-a small code region.
+..
+    So far all of the examples have used the default behaviors of the
+    decimal module. It is possible to override settings such as the
+    precision maintained, how rounding is performed, error handling,
+    etc. All of these settings are maintained via a *context*.  Contexts
+    can be applied for all Decimal instances in a thread or locally within
+    a small code region.
 
-Current Context
----------------
+これまでの全てのサンプルは、 :mod:`decimal` モジュールのデフォルトの処理を使用してきました。保持される精度、丸め、エラー処理といった設定は上書きできます。こういった全ての設定は *コンテキスト* 経由で行われます。コンテキストは、ローカルの小さなコード内か、スレッド内の全ての Decimal インスタンスに適用されます。
 
-To retrieve the current global context, use ``getcontext()``.
+..
+    Current Context
+    ---------------
+
+カレントコンテキスト
+--------------------
+
+..
+    To retrieve the current global context, use ``getcontext()``.
+
+カレントのグローバルコンテキストを取り出すには ``getcontext()`` を使用してください。
 
 .. include:: decimal_getcontext.py
     :literal:
 .. }}}
 .. {{{end}}}
 
+..
+    Precision
+    ---------
 
-Precision
----------
+精度
+----
 
-The *prec* attribute of the context controls the precision maintained
-for new values created as a result of arithmetic.  Literal values are
-maintained as described.
+..
+    The *prec* attribute of the context controls the precision maintained
+    for new values created as a result of arithmetic.  Literal values are
+    maintained as described.
+
+コンテキストの *prec* 属性は、計算の結果として生成される新たな値が保持する精度を制御します。リテラル値は前節で説明したように保持されます。
 
 .. include:: decimal_precision.py
     :literal:
 .. }}}
 .. {{{end}}}
 
+..
+    Rounding
+    --------
 
-Rounding
---------
+丸め
+----
 
-There are several options for rounding to keep values within the
-desired precision.
+..
+    There are several options for rounding to keep values within the
+    desired precision.
+
+必要な精度の範囲内に値が収まるように丸めのオプションがあります。
 
 ROUND_CEILING
-  Always round upwards towards infinity.
+  .. Always round upwards towards infinity.
+
+  常に正の無限大へ切り上げて丸める
 
 ROUND_DOWN
-  Always round toward zero.
+  .. Always round toward zero.
+
+  常にゼロ方向に丸める
 
 ROUND_FLOOR
-  Always round down towards negative infinity.
+  .. Always round down towards negative infinity.
+
+  常に負の無限大へ丸める
 
 ROUND_HALF_DOWN
-  Rounds away from zero if the last significant digit is greater than
-  or equal to 5, otherwise toward zero.
+  .. Rounds away from zero if the last significant digit is greater than
+     or equal to 5, otherwise toward zero.
+
+  最後の桁を五捨六入して丸める
 
 ROUND_HALF_EVEN
-  Like ROUND_HALF_DOWN except that if the value is 5 then the
-  preceding digit is examined.  Even values cause the result to be
-  rounded down and odd digits cause the result to be rounded up.
+  .. Like ROUND_HALF_DOWN except that if the value is 5 then the
+     preceding digit is examined.  Even values cause the result to be
+     rounded down and odd digits cause the result to be rounded up.
+
+  ROUND_HALF_DOWN と同じように処理されますが、最後の桁の値が 5 の場合、精度の桁を調べて、偶数なら切り捨て、奇数なら切り上げる
 
 ROUND_HALF_UP
-  Like ROUND_HALF_DOWN except if the last significant digit is 5 the
-  value is rounded away from zero.
+  .. Like ROUND_HALF_DOWN except if the last significant digit is 5 the
+     value is rounded away from zero.
+
+  ROUND_HALF_DOWN と同じように処理されますが、最後の桁を四捨五入する
 
 ROUND_UP
-  Round away from zero.
+  .. Round away from zero.
+
+  ゼロから遠い値に丸める
 
 ROUND_05UP
-  Round away from zero if the last digit is ``0`` or ``5``, otherwise
-  towards zero.
+  .. Round away from zero if the last digit is ``0`` or ``5``, otherwise
+     towards zero.
+
+  最後の桁が ``0`` か ``5`` ならゼロから遠い値へ、それ以外はゼロに丸める
 
 .. include:: decimal_rounding.py
     :literal:
 .. }}}
 .. {{{end}}}
 
-Local Context
--------------
+..
+    Local Context
+    -------------
 
-Using Python 2.5 or later you can also apply the context to a subset
-of your code using the ``with`` statement and a context manager.
+ローカルコンテキスト
+--------------------
+
+..
+    Using Python 2.5 or later you can also apply the context to a subset
+    of your code using the ``with`` statement and a context manager.
+
+Python 2.5 以上を使用することで、さらに ``with`` 文とコンテキストマネージャでコードのサブセットに対してコンテキストを適用することもできます。
 
 .. include:: decimal_context_manager.py
     :literal:
 .. }}}
 .. {{{end}}}
 
-Per-Instance Context
---------------------
+..
+    Per-Instance Context
+    --------------------
 
-Contexts can be used to construct Decimal instances, applying the precision and rounding arguments to the conversion from the input type.  This lets your application select the precision of constant values separately from the precision of user data.
+インスタンスごとのコンテキスト
+------------------------------
+
+..
+    Contexts can be used to construct Decimal instances, applying the precision and rounding arguments to the conversion from the input type.  This lets your application select the precision of constant values separately from the precision of user data.
+
+コンテキストは、精度の適用して入力の型から引数を丸めるように変換しながら、Decimal インスタンス作成するのに使用できます。これによりアプリケーションは、ユーザデータの精度から定数の値の精度を分離して選択できます。
 
 .. include:: decimal_instance_context.py
     :literal:
 .. }}}
 .. {{{end}}}
 
+..
+    Threads
+    -------
 
-Threads
--------
+スレッド
+--------
 
-The "global" context is actually thread-local, so each thread can potentially be configured using different values.
+..
+    The "global" context is actually thread-local, so each thread can potentially be configured using different values.
+
+"グローバル" コンテキストは、実際にはスレッドローカルなので、それぞれのスレッドは潜在的に違う値を設定できます。
 
 .. include:: decimal_thread_context.py
     :literal:
 .. seealso::
 
     `decimal <http://docs.python.org/library/decimal.html>`_
-        The standard library documentation for this module.
+        .. The standard library documentation for this module.
+
+        本モジュールの標準ライブラリドキュメント
 
     `Wikipedia: Floating Point <http://en.wikipedia.org/wiki/Floating_point>`_
-        Article on floating point representations and arithmetic.
+        .. Article on floating point representations and arithmetic.
+
+        浮動小数点数表現と数値に関する記事