📄 numerical.sgml
字号:
<refentry id="glib-Numerical-Definitions"><refmeta><refentrytitle>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><refsynopsisdiv><title>Synopsis</title><synopsis>#include <glib.h>#define <link linkend="G-IEEE754-FLOAT-BIAS-CAPS">G_IEEE754_FLOAT_BIAS</link>#define <link linkend="G-IEEE754-DOUBLE-BIAS-CAPS">G_IEEE754_DOUBLE_BIAS</link>union <link linkend="GFloatIEEE754">GFloatIEEE754</link>;union <link linkend="GDoubleIEEE754">GDoubleIEEE754</link>;#define <link linkend="G-E-CAPS">G_E</link>#define <link linkend="G-LN2-CAPS">G_LN2</link>#define <link linkend="G-LN10-CAPS">G_LN10</link>#define <link linkend="G-PI-CAPS">G_PI</link>#define <link linkend="G-PI-2-CAPS">G_PI_2</link>#define <link linkend="G-PI-4-CAPS">G_PI_4</link>#define <link linkend="G-SQRT2-CAPS">G_SQRT2</link>#define <link linkend="G-LOG-2-BASE-10-CAPS">G_LOG_2_BASE_10</link></synopsis></refsynopsisdiv><refsect1><title>Description</title><para>GLib offers mathematical constants such as <link linkend="G-PI-CAPS">G_PI</link> for the value of pi;many platforms have these in the C library, but some don't, the GLibversions always exist.</para><para>The <link linkend="GFloatIEEE754">GFloatIEEE754</link> and <link linkend="GDoubleIEEE754">GDoubleIEEE754</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, for reference: <ulink url="http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html">http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html</ulink></para></refsect1><refsect1><title>Details</title><refsect2><title><anchor id="G-IEEE754-FLOAT-BIAS-CAPS">G_IEEE754_FLOAT_BIAS</title><programlisting>#define G_IEEE754_FLOAT_BIAS (127)</programlisting><para>See <ulink url="http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html">http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html</ulink></para></refsect2><refsect2><title><anchor id="G-IEEE754-DOUBLE-BIAS-CAPS">G_IEEE754_DOUBLE_BIAS</title><programlisting>#define G_IEEE754_DOUBLE_BIAS (1023)</programlisting><para>See <ulink url="http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html">http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html</ulink></para></refsect2><refsect2><title><anchor id="GFloatIEEE754">union GFloatIEEE754</title><programlisting>union GFloatIEEE754{ gfloat v_float; struct { guint mantissa : 23; guint biased_exponent : 8; guint sign : 1; } mpn;};</programlisting><para>The <link linkend="GFloatIEEE754">GFloatIEEE754</link> and <link linkend="GDoubleIEEE754">GDoubleIEEE754</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, for reference: <ulink url="http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html">http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html</ulink></para></refsect2><refsect2><title><anchor id="GDoubleIEEE754">union GDoubleIEEE754</title><programlisting>union GDoubleIEEE754{ gdouble v_double; struct { guint mantissa_low : 32; guint mantissa_high : 20; guint biased_exponent : 11; guint sign : 1; } mpn;};</programlisting><para>The <link linkend="GFloatIEEE754">GFloatIEEE754</link> and <link linkend="GDoubleIEEE754">GDoubleIEEE754</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, for reference: <ulink url="http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html">http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html</ulink></para></refsect2><refsect2><title><anchor id="G-E-CAPS">G_E</title><programlisting>#define G_E 2.7182818284590452354E0</programlisting><para>The base of natural logarithms.</para></refsect2><refsect2><title><anchor id="G-LN2-CAPS">G_LN2</title><programlisting>#define G_LN2 6.9314718055994530942E-1</programlisting><para>The natural logarithm of 2.</para></refsect2><refsect2><title><anchor id="G-LN10-CAPS">G_LN10</title><programlisting>#define G_LN10 2.3025850929940456840E0</programlisting><para>The natural logarithm of 10.</para></refsect2><refsect2><title><anchor id="G-PI-CAPS">G_PI</title><programlisting>#define G_PI 3.14159265358979323846E0</programlisting><para>The value of pi (ratio of circle's circumference to its diameter).</para></refsect2><refsect2><title><anchor id="G-PI-2-CAPS">G_PI_2</title><programlisting>#define G_PI_2 1.57079632679489661923E0</programlisting><para>Pi divided by 2.</para></refsect2><refsect2><title><anchor id="G-PI-4-CAPS">G_PI_4</title><programlisting>#define G_PI_4 0.78539816339744830962E0</programlisting><para>Pi divided by 4.</para></refsect2><refsect2><title><anchor id="G-SQRT2-CAPS">G_SQRT2</title><programlisting>#define G_SQRT2 1.4142135623730950488E0</programlisting><para>The square root of two.</para></refsect2><refsect2><title><anchor id="G-LOG-2-BASE-10-CAPS">G_LOG_2_BASE_10</title><programlisting>#define G_LOG_2_BASE_10 (0.30102999566398119521)</programlisting><para>Used for fooling around with float formats, see <ulink url="http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html">http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html</ulink></para></refsect2></refsect1><refsect1><title>See Also</title><para><ulink url="http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html">http://twister.ou.edu/workshop.docs/common-tools/numerical_comp_guide/ncg_math.doc.html</ulink></para></refsect1></refentry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -