<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
                      'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd' [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="glib-Numerical-Definitions">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Numerical-Definitions.top_of_page">Numerical Definitions</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Numerical Definitions</refname>
<refpurpose>mathematical constants, and floating point decomposition</refpurpose>
</refnamediv>

<refsect1 id="glib-Numerical-Definitions.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="name" colwidth="150px"/>
<colspec colname="description"/>
<tbody>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-IEEE754-FLOAT-BIAS:CAPS">G_IEEE754_FLOAT_BIAS</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-IEEE754-DOUBLE-BIAS:CAPS">G_IEEE754_DOUBLE_BIAS</link></entry></row>
<row><entry role="datatype_keyword">union</entry><entry role="function_name"><link linkend="GFloatIEEE754">GFloatIEEE754</link></entry></row>
<row><entry role="datatype_keyword">union</entry><entry role="function_name"><link linkend="GDoubleIEEE754">GDoubleIEEE754</link></entry></row>

<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-E:CAPS">G_E</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-LN2:CAPS">G_LN2</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-LN10:CAPS">G_LN10</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-PI:CAPS">G_PI</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-PI-2:CAPS">G_PI_2</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-PI-4:CAPS">G_PI_4</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-SQRT2:CAPS">G_SQRT2</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="G-LOG-2-BASE-10:CAPS">G_LOG_2_BASE_10</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 id="glib-Numerical-Definitions.includes"><title>Includes</title><synopsis>#include &lt;glib.h&gt;
</synopsis></refsect1>

<refsect1 id="glib-Numerical-Definitions.description" role="desc">
<title role="desc.title">Description</title>
<para>GLib offers mathematical constants such as <link linkend="G-PI:CAPS"><type>G_PI</type></link> for the value of pi;
many platforms have these in the C library, but some don't, the GLib
versions always exist.</para>
<para>The <link linkend="GFloatIEEE754"><type>GFloatIEEE754</type></link> and <link linkend="GDoubleIEEE754"><type>GDoubleIEEE754</type></link> unions are used to access the
sign, mantissa and exponent of IEEE floats and doubles. These unions are
defined as appropriate for a given platform. IEEE floats and doubles are
supported (used for storage) by at least Intel, PPC and Sparc. See
<ulink url="http://en.wikipedia.org/wiki/IEEE_float">IEEE 754-2008</ulink>
for more information about IEEE number formats.</para>

</refsect1>
<refsect1 id="glib-Numerical-Definitions.functions_details" role="details">
<title role="details.title">Functions</title>
<para />
</refsect1>
<refsect1 id="glib-Numerical-Definitions.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="G-IEEE754-FLOAT-BIAS:CAPS" role="macro">
<title>G_IEEE754_FLOAT_BIAS</title>
<indexterm zone="G-IEEE754-FLOAT-BIAS:CAPS"><primary sortas="IEEE754_FLOAT_BIAS">G_IEEE754_FLOAT_BIAS</primary></indexterm>
<programlisting language="C">#define G_IEEE754_FLOAT_BIAS&#160;(127)
</programlisting>
<para>The bias by which exponents in single-precision floats are offset.</para>
</refsect2>
<refsect2 id="G-IEEE754-DOUBLE-BIAS:CAPS" role="macro">
<title>G_IEEE754_DOUBLE_BIAS</title>
<indexterm zone="G-IEEE754-DOUBLE-BIAS:CAPS"><primary sortas="IEEE754_DOUBLE_BIAS">G_IEEE754_DOUBLE_BIAS</primary></indexterm>
<programlisting language="C">#define G_IEEE754_DOUBLE_BIAS&#160;(1023)
</programlisting>
<para>The bias by which exponents in double-precision floats are offset.</para>
</refsect2>
<refsect2 id="GFloatIEEE754" role="union">
<title>union GFloatIEEE754</title>
<indexterm zone="GFloatIEEE754"><primary sortas="FloatIEEE754">GFloatIEEE754</primary></indexterm>
<para>The <link linkend="GFloatIEEE754"><type>GFloatIEEE754</type></link> and <link linkend="GDoubleIEEE754"><type>GDoubleIEEE754</type></link> unions are used to access the sign,
mantissa and exponent of IEEE floats and doubles. These unions are defined
as appropriate for a given platform. IEEE floats and doubles are supported
(used for storage) by at least Intel, PPC and Sparc.</para>
<refsect3 id="GFloatIEEE754.members" role="union_members">
<title>Members</title>
<informaltable role="union_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="union_members_name" colwidth="300px"/>
<colspec colname="union_members_description"/>
<colspec colname="union_members_annotations" colwidth="200px"/>
<tbody>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="GDoubleIEEE754" role="union">
<title>union GDoubleIEEE754</title>
<indexterm zone="GDoubleIEEE754"><primary sortas="DoubleIEEE754">GDoubleIEEE754</primary></indexterm>
<para>The <link linkend="GFloatIEEE754"><type>GFloatIEEE754</type></link> and <link linkend="GDoubleIEEE754"><type>GDoubleIEEE754</type></link> unions are used to access the sign,
mantissa and exponent of IEEE floats and doubles. These unions are defined
as appropriate for a given platform. IEEE floats and doubles are supported
(used for storage) by at least Intel, PPC and Sparc.</para>
<refsect3 id="GDoubleIEEE754.members" role="union_members">
<title>Members</title>
<informaltable role="union_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="union_members_name" colwidth="300px"/>
<colspec colname="union_members_description"/>
<colspec colname="union_members_annotations" colwidth="200px"/>
<tbody>
<row><entry role="union_member_name"><para><link linkend="gdouble"><type>gdouble</type></link>&#160;<structfield id="GDoubleIEEE754.v-double">v_double</structfield>;</para></entry>
<entry role="union_member_description"><para>the double value</para></entry>
<entry role="union_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="G-E:CAPS" role="macro">
<title>G_E</title>
<indexterm zone="G-E:CAPS"><primary sortas="E">G_E</primary></indexterm>
<programlisting language="C">#define G_E     2.7182818284590452353602874713526624977572470937000
</programlisting>
<para>The base of natural logarithms.</para>
</refsect2>
<refsect2 id="G-LN2:CAPS" role="macro">
<title>G_LN2</title>
<indexterm zone="G-LN2:CAPS"><primary sortas="LN2">G_LN2</primary></indexterm>
<programlisting language="C">#define G_LN2   0.69314718055994530941723212145817656807550013436026
</programlisting>
<para>The natural logarithm of 2.</para>
</refsect2>
<refsect2 id="G-LN10:CAPS" role="macro">
<title>G_LN10</title>
<indexterm zone="G-LN10:CAPS"><primary sortas="LN10">G_LN10</primary></indexterm>
<programlisting language="C">#define G_LN10  2.3025850929940456840179914546843642076011014886288
</programlisting>
<para>The natural logarithm of 10.</para>
</refsect2>
<refsect2 id="G-PI:CAPS" role="macro">
<title>G_PI</title>
<indexterm zone="G-PI:CAPS"><primary sortas="PI">G_PI</primary></indexterm>
<programlisting language="C">#define G_PI    3.1415926535897932384626433832795028841971693993751
</programlisting>
<para>The value of pi (ratio of circle's circumference to its diameter).</para>
</refsect2>
<refsect2 id="G-PI-2:CAPS" role="macro">
<title>G_PI_2</title>
<indexterm zone="G-PI-2:CAPS"><primary sortas="PI_2">G_PI_2</primary></indexterm>
<programlisting language="C">#define G_PI_2  1.5707963267948966192313216916397514420985846996876
</programlisting>
<para>Pi divided by 2.</para>
</refsect2>
<refsect2 id="G-PI-4:CAPS" role="macro">
<title>G_PI_4</title>
<indexterm zone="G-PI-4:CAPS"><primary sortas="PI_4">G_PI_4</primary></indexterm>
<programlisting language="C">#define G_PI_4  0.78539816339744830961566084581987572104929234984378
</programlisting>
<para>Pi divided by 4.</para>
</refsect2>
<refsect2 id="G-SQRT2:CAPS" role="macro">
<title>G_SQRT2</title>
<indexterm zone="G-SQRT2:CAPS"><primary sortas="SQRT2">G_SQRT2</primary></indexterm>
<programlisting language="C">#define G_SQRT2 1.4142135623730950488016887242096980785696718753769
</programlisting>
<para>The square root of two.</para>
</refsect2>
<refsect2 id="G-LOG-2-BASE-10:CAPS" role="macro">
<title>G_LOG_2_BASE_10</title>
<indexterm zone="G-LOG-2-BASE-10:CAPS"><primary sortas="LOG_2_BASE_10">G_LOG_2_BASE_10</primary></indexterm>
<programlisting language="C">#define G_LOG_2_BASE_10		(0.30102999566398119521)
</programlisting>
<para>Multiplying the base 2 exponent by this number yields the base 10 exponent.</para>
</refsect2>

</refsect1>

</refentry>
