1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Numeric Generators</title> 5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Spirit 2.5.8"> 8<link rel="up" href="../reference.html" title="Reference"> 9<link rel="prev" href="nonterminal/grammar.html" title="Generator Grammar"> 10<link rel="next" href="numeric/unsigned_int.html" title="Unsigned Integer Number Generators (uint_, etc.)"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="nonterminal/grammar.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="numeric/unsigned_int.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="spirit.karma.reference.numeric"></a><a class="link" href="numeric.html" title="Numeric Generators">Numeric Generators</a> 28</h4></div></div></div> 29<div class="toc"><dl class="toc"> 30<dt><span class="section"><a href="numeric/unsigned_int.html">Unsigned 31 Integer Number Generators (<code class="computeroutput"><span class="identifier">uint_</span></code>, 32 etc.)</a></span></dt> 33<dt><span class="section"><a href="numeric/signed_int.html">Signed 34 Integer Number Generators (<code class="computeroutput"><span class="identifier">int_</span></code>, 35 etc.)</a></span></dt> 36<dt><span class="section"><a href="numeric/real_number.html">Real 37 Number Generators (<code class="computeroutput"><span class="identifier">float_</span></code>, 38 <code class="computeroutput"><span class="identifier">double_</span></code>, etc.)</a></span></dt> 39<dt><span class="section"><a href="numeric/boolean.html">Boolean Generators 40 (<code class="computeroutput"><span class="identifier">bool_</span></code>)</a></span></dt> 41</dl></div> 42<p> 43 The library includes a couple of predefined objects for generating booleans, 44 signed and unsigned integers, and real numbers. These generators are fully 45 parametric. Most of the important aspects of numeric generation can be 46 finely adjusted to suit. This includes the radix base, the exponent, the 47 fraction etc. Policies control the real number generators' behavior. There 48 are some predefined policies covering the most common real number formats 49 but the user can supply her own when needed. 50 </p> 51<p> 52 The numeric parsers are fine tuned (employing loop unrolling and extensive 53 template metaprogramming) with exceptional performance that rivals the 54 low level C functions such as <code class="computeroutput"><span class="identifier">ltoa</span></code>, 55 <code class="computeroutput"><span class="identifier">ssprintf</span></code>, and <code class="computeroutput"><span class="identifier">_gcvt</span></code>. Benchmarks reveal up to 2X speed 56 over the C counterparts (see here: <a class="link" href="../performance_measurements/numeric_performance.html" title="Performance of Numeric Generators">Performance 57 of Numeric Generators</a>). This goes to show that you can write extremely 58 tight generic C++ code that rivals, if not surpasses C. 59 </p> 60<h6> 61<a name="spirit.karma.reference.numeric.h0"></a> 62 <span class="phrase"><a name="spirit.karma.reference.numeric.module_header"></a></span><a class="link" href="numeric.html#spirit.karma.reference.numeric.module_header">Module 63 Header</a> 64 </h6> 65<pre class="programlisting"><span class="comment">// forwards to <boost/spirit/home/karma/numeric.hpp></span> 66<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma_numeric</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 67</pre> 68<p> 69 Also, see <a class="link" href="../../structure/include.html" title="Include">Include Structure</a>. 70 </p> 71</div> 72<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 73<td align="left"></td> 74<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p> 75 Distributed under the Boost Software License, Version 1.0. (See accompanying 76 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 77 </p> 78</div></td> 79</tr></table> 80<hr> 81<div class="spirit-nav"> 82<a accesskey="p" href="nonterminal/grammar.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="numeric/unsigned_int.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 83</div> 84</body> 85</html> 86