From: Raymond H. <py...@rc...> - 2009-04-21 04:09:21
|
10.2.1.5. Decimal URI: tag:yaml.org,2009:decimal Kind: Scalar. Definition: Represents an exact decimal value, including special values (positive and negative infinity, and "not a number"). Some languages (such as Python, Rexx, Java and many SQL variants) provide support for exact decimal values. Additionally, standards exist for representing and manipulating those values ( http://speleotrove.com/decimal/decarith.html and http://754r.ucbtest.org/standards/854.pdf ). Unlike numbers tagged with !!float, the !!decimal tagged values provide a lossless means of transmitting numbers (all decimal values have exact representations and even binary floating point values can be exchanged in a platform independent manner since all binary floating point numbers have exact representations in decimal). Canonical Form: sign ::= '+' | '-' digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' indicator ::= 'e' | 'E' digits ::= digit [digit]... decimal-part ::= digits '.' [digits] | ['.'] digits exponent-part ::= indicator [sign] digits infinity ::= 'Infinity' | 'Inf' nan ::= 'NaN' [digits] | 'sNaN' [digits] numeric-value ::= decimal-part [exponent-part] | infinity numeric-string ::= [sign] numeric-value | [sign] nan where the characters in the strings accepted for infinity and nan may be in any case. If an implementation supports the concept of diagnostic information on NaNs, the numeric strings for NaNs may include one or more digits, as shown above.[3] These digits encode the diagnostic information in an implementation-defined manner; however, conversions to and from string for diagnostic NaNs should be reversible if possible. If an implementation does not support diagnostic information on NaNs, these digits should be ignored where necessary. A plain 'NaN' is usually the same as 'NaN0'. Examples: zero: !!decimal 0 whole number: !!decimal 12 signed whole number: !!decimal -76 signficant trailing zeros: !!decimal 12.70 with plus sign: !!decimal +0.003 leading zeros: !!decimal 017. half: !!decimal .5 exponential: !!decimal 4E+9 exponential negative power: !!decimal 0.73e-7 infinity: !!decimal Inf negative infinity: !!decimal -infinity not a number: !!decimal NaN diagnostic nan: !!decimal NaN8275 Submitted by: Raymond Hettinger |