Part of twisted.protocols.amp View Source View In Hierarchy
decimal.Decimal
instances.
There are several ways in which a decimal value might be encoded.
Special values are encoded as special strings:
- Positive infinity is encoded as C{"Infinity"} - Negative infinity is encoded as C{"-Infinity"} - Quiet not-a-number is encoded as either C{"NaN"} or C{"-NaN"} - Signalling not-a-number is encoded as either C{"sNaN"} or C{"-sNaN"}
Normal values are encoded using the base ten string representation, using engineering notation to indicate magnitude without precision, and "normal" digits to indicate precision. For example:
- C{"1"} represents the value I{1} with precision to one place. - C{"-1"} represents the value I{-1} with precision to one place. - C{"1.0"} represents the value I{1} with precision to two places. - C{"10"} represents the value I{10} with precision to two places. - C{"1E+2"} represents the value I{10} with precision to one place. - C{"1E-1"} represents the value I{0.1} with precision to one place. - C{"1.5E+2"} represents the value I{15} with precision to two places.
http://speleotrove.com/decimal/ should be considered the authoritative specification for the format.
Method | toString | Serialize a decimal.Decimal instance to the specified wire
format. |
Inherited from Argument:
Method | __init__ | Create an Argument. |
Method | retrieve | Retrieve the given key from the given dictionary, removing it if found. |
Method | fromBox | Populate an 'out' dictionary with mapping names to Python values decoded from an 'in' AmpBox mapping strings to string values. |
Method | toBox | Populate an 'out' AmpBox with strings encoded from an 'in' dictionary mapping names to Python values. |
Method | fromStringProto | Convert a string to a Python value. |
Method | toStringProto | Convert a Python object to a string. |
Method | fromString | Convert a string to a Python object. Subclasses must implement this. |
decimal.Decimal
instance to the specified wire
format.