root/trunk/spec/float.dbk

Revision 7, 5.0 KB (checked in by oren, 8 months ago)

April 06, 2008 draft.

Implemented by YamlReference? 0.9.

Contains new productions, new examples, all the changes collected throughout
the last 3 years, and of course JSON compatibility.

Line 
1<?xml version="1.0"?>
2<!DOCTYPE article
3  PUBLIC "-//OASIS//DTD DocBook V4.2//EN"
4         "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5
6<article>
7  <articleinfo>
8    <title>
9      Floating-Point Language-Independent Type for
10      <trademark>YAML</trademark>&nbsp;Version&nbsp;1.1
11    </title>
12
13    <subtitle>
14      Working Draft 2005-01-18-FIXED!!!
15    </subtitle>
16
17    <authorgroup>
18      <author>
19        <firstname>Oren</firstname>
20        <surname>Ben-Kiki</surname>
21        <email>oren@ben-kiki.org</email>
22      </author>
23
24      <author>
25        <firstname>Clark</firstname>
26        <surname>Evans</surname>
27        <email>cce+yaml@clarkevans.com</email>
28      </author>
29
30      <author>
31        <firstname>Brian</firstname>
32        <surname>Ingerson</surname>
33        <email>ingy@ttul.org</email>
34      </author>
35    </authorgroup>
36
37    <copyright>
38      <year>2001-2005</year>
39      <holder>Oren Ben-Kiki<fo>,&nbsp;</fo></holder>
40      <holder>Clark Evans<fo>,&nbsp;</fo></holder>
41      <holder>Brian Ingerson</holder>
42    </copyright>
43
44    <legalnotice>
45      This document may be freely copied provided it is not modified.
46    </legalnotice>
47
48    <abstract>
49      <title>Status</title>
50
51      <para>
52       This specification is a draft reflecting consensus reached by members of
53       the <ulink
54       url="http://lists.sourceforge.net/lists/listinfo/yaml-core">yaml-core
55       mailing list</ulink>. Any questions regarding this draft should be
56       raised on this list.
57      </para>
58    </abstract>
59  </articleinfo>
60
61  <section>
62    <variablelist>
63      <varlistentry>
64        <term>
65          <para>
66            URI:
67          </para>
68        </term>
69
70        <listitem>
71          <para>
72            <userinput>tag:yaml.org,2002:float</userinput>
73          </para>
74        </listitem>
75      </varlistentry>
76
77      <varlistentry>
78        <term>
79          <para>
80            Shorthand:
81          </para>
82        </term>
83
84        <listitem>
85          <para>
86            <userinput>!!float</userinput>
87          </para>
88        </listitem>
89      </varlistentry>
90
91      <varlistentry>
92        <term>
93          <para>
94            Kind:
95          </para>
96        </term>
97
98        <listitem>
99          <para>
100            Scalar.
101          </para>
102        </listitem>
103      </varlistentry>
104
105      <varlistentry>
106        <term>
107          <para>
108            Canonical:
109          </para>
110        </term>
111
112        <listitem>
113<screen>
114 0
115|[-]?[1-9]\.([0-9]*[1-9])?e[-+](0|[1-9][0-9]+) <lineannotation>(scientific)</lineannotation>
116|-?\.inf <lineannotation>(infinity)</lineannotation>
117|\.nan <lineannotation>(not a number)</lineannotation>
118</screen>
119        </listitem>
120      </varlistentry>
121
122      <varlistentry>
123        <term>Regexp:</term>
124        <listitem>
125<screen>
126 [-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)? <lineannotation>(base 10)</lineannotation>
127|[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]* <lineannotation>(base 60)</lineannotation>
128|[-+]?\.(inf|Inf|INF) <lineannotation># (infinity)</lineannotation>
129|\.(nan|NaN|NAN) <lineannotation># (not a number)</lineannotation>
130</screen>
131        </listitem>
132      </varlistentry>
133
134      <varlistentry>
135        <term>
136          <para>
137            Definition:
138          </para>
139        </term>
140
141        <listitem>
142          <para>
143            Floating-point approximation to real numbers.
144          </para>
145
146          <para>
147            Floating-point numbers are approximations to real numbers,
148            including three special values (positive and negative infinity and
149            <quote>not a number</quote>). Using
150            <quote><userinput>:</userinput></quote> allows expressing the
151            integer part in base 60, which is convenient for time and angle
152            values (the fractional part is always in base 10). Any
153            <quote><userinput>_</userinput></quote> characters in the number
154            are ignored, allowing a readable representation of large values.
155          </para>
156
157          <para>
158            This should be loaded to some native float data type. The processor
159            may choose from a range of such native data types according to the
160            size and accuracy of the floating-point value. Note that not all
161            floating-point values can be represented exactly when stored in any
162            native float type, and hence a float value may change by <quote>a
163            small amount</quote> when round-tripped through a native type. The
164            valid range and accuracy depends on the implementation, though 32
165            bit IEEE floats should be safe. Since YAML does not specify a
166            particular accuracy, using floating-point mapping keys requires
167            great care and is not recommended.
168          </para>
169        </listitem>
170      </varlistentry>
171    </variablelist>
172
173    <example>
174      <title><userinput>!!float</userinput> Examples</title>
175<programlisting>
176canonical: 6.8523015e+5
177exponentioal: 685.230_15e+03
178fixed: 685_230.15
179sexagesimal: 190:20:30.15
180negative infinity: -.inf
181not a number: .NaN
182</programlisting>
183    </example>
184  </section>
185</article>
Note: See TracBrowser for help on using the browser.