Proposed tag: decimal

"Raymond Hettinger" <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <3F557B9B3C3C44ACA6B8BFA9A211CE30@RaymondLaptop1>
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



 


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.