📄 blitz_10.html
字号:
<HTML><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><!-- Created on November, 4 2004 by texi2html 1.64 --><!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) Karl Berry <karl@freefriends.org> Olaf Bachmann <obachman@mathematik.uni-kl.de> and many others.Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> --><HEAD><TITLE>Blitz++: Numeric properties</TITLE><META NAME="description" CONTENT="Blitz++: Numeric properties"><META NAME="keywords" CONTENT="Blitz++: Numeric properties"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META NAME="Generator" CONTENT="texi2html 1.64"></HEAD><BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"><A NAME="SEC152"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_9.html#SEC151"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC153"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_2.html#SEC28"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_11.html#SEC155"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H1> 10. Numeric properties </H1><!--docid::SEC152::--><P><HR SIZE="6"><A NAME="SEC153"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC152"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC154"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC152"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC152"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_11.html#SEC155"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 10.1 Introduction </H2><!--docid::SEC153::--><P><A NAME="IDX364"></A></P><P>Blitz++ provides a set of functions to access numeric properties ofintrinsic types. They are provided as an alternative to the somewhat klunky<CODE>numeric_limits<T>::yadda_yadda</CODE> syntax provided by the ISO/ANSI C++standard. Where a similar Fortran 90 function exists, the same name hasbeen used.</P><P>The argument in all cases is a dummy of the appropriate type.</P><P>All functions described in this section assume that <CODE>numeric_limits<T></CODE>has been specialized for the appropriate case. If not, the results are notuseful. The standard requires that <CODE>numeric_limits<T></CODE> be specializedfor all the intrinsic numeric types (float, double, int, bool, unsigned int,etc.).</P><P><A NAME="IDX365"></A></P><P>To use these functions, you must first include the header<CODE><blitz/numinquire.h></CODE>. Also, note that these functions may beunavailable if your compiler is non-ANSI compliant. If the preprocessorsymbol <CODE>BZ_HAVE_NUMERIC_LIMITS</CODE> is false, then these functions areunavailable.</P><P><HR SIZE="6"><A NAME="SEC154"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC153"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_11.html#SEC155"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC152"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC152"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_11.html#SEC155"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 10.2 Function descriptions </H2><!--docid::SEC154::--><P><DL COMPACT><DT><CODE>T denorm_min(T) throw;</CODE><DD><A NAME="IDX366"></A>Minimum positive denormalized value. Available for floating-pointtypes only. <P><DT><CODE>int digits(T);</CODE><DD><A NAME="IDX367"></A>The number of radix digits (read: bits) in the mantissa. Also works forinteger types. The official definition is "number of radix digits that canbe represented without change". <P><DT><CODE>int digits10(T);</CODE><DD><A NAME="IDX368"></A>The number of base-10 digits that can be represented withoutchange. <P><DT><CODE>T epsilon(T);</CODE><DD><A NAME="IDX369"></A>The smallest amount which can be added to 1 to produce a result which is not1. Floating-point types only.<P><DT><CODE>bool has_denorm(T);</CODE><DD><A NAME="IDX370"></A><A NAME="IDX371"></A>True if the representation allows denormalized values (floating-pointonly).<P><DT><CODE>bool has_denorm_loss(T);</CODE><DD><A NAME="IDX372"></A><A NAME="IDX373"></A>True if a loss of precision is detected as a denormalization loss, ratherthan as an inexact result (floating-point only). <P><DT><CODE>bool has_infinity(T);</CODE><DD><A NAME="IDX374"></A><A NAME="IDX375"></A>True if there is a special representation for the value "infinity". Iftrue, the representation can be obtained by calling <CODE>infinity(T)</CODE>.<P><DT><CODE>bool has_quiet_NaN(T);</CODE><DD><A NAME="IDX376"></A><A NAME="IDX377"></A>True if there is a special representation for a quiet (non-signalling) Not ANumber (<CODE>NaN</CODE>). If so, use the function <CODE>quiet_NaN(T)</CODE> to obtain it. <P><DT><CODE>bool has_signaling_NaN(T);</CODE><DD><A NAME="IDX378"></A><A NAME="IDX379"></A>True if there is a special representation for a signalling Not A Number(<CODE>NaN</CODE>). If so, use the function <CODE>signalling_NaN(T)</CODE> to obtain it. <P><DT><CODE>bool has_signalling_NaN(T);</CODE><DD><A NAME="IDX380"></A>Same as <CODE>has_signaling_NaN()</CODE>.<P><DT><CODE>T huge(T) throw;</CODE><DD><A NAME="IDX381"></A><A NAME="IDX382"></A>Returns the maximum finite representable value. Equivalent to<CODE>CHAR_MAX</CODE>, <CODE>SHRT_MAX</CODE>, <CODE>FLT_MAX</CODE>, etc. For floating typeswith denormalization, the maximum positive <STRONG>normalized</STRONG> value isreturned. <P><DT><CODE>T infinity(T) throw;</CODE><DD><A NAME="IDX383"></A>Returns the representation of positive infinity, if available. Note thatyou should check availability with <CODE>has_infinity(T)</CODE> before callingthis function. <P><DT><CODE>bool is_bounded(T);</CODE><DD><A NAME="IDX384"></A>True if the set of values represented by the type is finite. All built-intypes are bounded. (This function was provided so that e.g. arbitraryprecision types could be distinguished).<P><DT><CODE>bool is_exact(T);</CODE><DD><A NAME="IDX385"></A>True if the representation is exact. All integer types are exact;floating-point types generally aren't. A rational arithmetic type could beexact. <P><DT><CODE>bool is_iec559(T);</CODE><DD><A NAME="IDX386"></A><A NAME="IDX387"></A>True if the type conforms to the IEC 559 standard. IEC is the InternationalElectrotechnical Commission. Note that IEC 559 is the same as IEEE 754.Only relevant for floating types.<P><DT><CODE>bool is_integer(T);</CODE><DD><A NAME="IDX388"></A>True if the type is integer. <P><DT><CODE>bool is_modulo(T);</CODE><DD><A NAME="IDX389"></A>True if the type is modulo. Integer types are usually modulo: if you addtwo integers, they might wrap around and give you a small result. (Somespecial kinds of integers don't wrap around, but stop at an upper or lowerbound; this is called saturating arithmetic). This is false for floatingtypes. <P><DT><CODE>bool is_signed(T);</CODE><DD><A NAME="IDX390"></A><A NAME="IDX391"></A>True if the type is signed (i.e. can handle both positive and negativevalues). <P><DT><CODE>int max_exponent(T);</CODE><DD><A NAME="IDX392"></A>The maximum exponent (<CODE>Max_exp</CODE>) is the maximum positive integer suchthat the radix (read: 2) raised to the power <CODE>Max_exp-1</CODE> is arepresentable, finite floating point number. Floating types only. <P><DT><CODE>int max_exponent10(T);</CODE><DD><A NAME="IDX393"></A>The maximum base-10 exponent (<CODE>Max_exp10</CODE>) is the maximum positiveinteger such that 10 raised to the power <CODE>Max_exp10</CODE> is arepresentable, finite floating point number. Floating types only. <P><DT><CODE>int min_exponent(T);</CODE><DD><A NAME="IDX394"></A>The minimum exponent (<CODE>Min_exp</CODE>) is the minimum negative integer suchthat the radix (read: 2) raised to the power <CODE>Min_exp-1</CODE> is a<STRONG>normalized</STRONG> floating point number. Floating types only. <P><DT><CODE>int min_exponent10(T);</CODE><DD><A NAME="IDX395"></A>The minimum base-10 exponent (<CODE>Min_exp10</CODE>) is the minimum negative integersuch that 10 raised to the power <CODE>Min_exp10</CODE> is in the range of<STRONG>normalized</STRONG> floating point numbers. <P><DT><CODE>T neghuge(T);</CODE><DD><A NAME="IDX396"></A><A NAME="IDX397"></A>This returns the maximally negative value for a type. For integers, this isthe same as min(). For floating-point types, it is <CODE>-huge(T())</CODE>.<P><DT><CODE>T one(T);</CODE><DD><A NAME="IDX398"></A>Returns a representation for "1" <P><DT><CODE>int precision(T);</CODE><DD><A NAME="IDX399"></A>Same as <CODE>digits10()</CODE>. <P><DT><CODE>T quiet_NaN(T) throw;</CODE><DD><A NAME="IDX400"></A><A NAME="IDX401"></A>Returns the representation for a quiet (non-signalling) Not A Number(<CODE>NaN</CODE>), if available. You should check availability using the<CODE>has_quiet_NaN(T)</CODE> function first. <P><DT><CODE>int radix(T);</CODE><DD><A NAME="IDX402"></A>For floating-point types, this returns the radix (base) of the exponent.For integers, it specifies the base of the representation.<P><DT><CODE>Range range(T);</CODE><DD><A NAME="IDX403"></A>Returns <CODE>Range(min_exponent10(T()), max_exponent10(T()))</CODE>, i.e. therange of representable base-10 exponents. <P><DT><CODE>T round_error(T) throw;</CODE><DD><A NAME="IDX404"></A>Returns a measure of the maximum rounding error for floating-point types.This will typically be <CODE>0.5</CODE>. <P><DT><CODE>std::float_round_style round_style(T);</CODE><DD><A NAME="IDX405"></A>Returns the current rounding style for floating-point arithmetic. Thepossibilities are: <CODE>round_indeterminate</CODE> (i.e. don't have a clue),<CODE>round_toward_zero</CODE>, <CODE>round_to_nearest</CODE> (round to nearestrepresentable value), <CODE>round_toward_infinity</CODE> (round toward positiveinfinity), and <CODE>round_neg_infinity</CODE> (round toward negative infinity). <P><DT><CODE>T signaling_NaN(T) throw;</CODE><DD><A NAME="IDX406"></A>Returns the representation for a signalling Not A Number (<CODE>NaN</CODE>), ifavailable. You should check availability by calling<CODE>has_signalling_NaN(T)</CODE> first. <P><DT><CODE>T signalling_NaN(T) throw;</CODE><DD><A NAME="IDX407"></A>Same as <CODE>signaling_NaN()</CODE>.<P><DT><CODE>T tiny(T);</CODE><DD><A NAME="IDX408"></A><A NAME="IDX409"></A>For integer types, this returns the minimum finite value, which may benegative. For floating types, it returns the minimum positive value. Forfloating types with denormalization, the function returns the minimumpositive <STRONG>normalized</STRONG> value. <P><DT><CODE>T tinyness_before(T);</CODE><DD><A NAME="IDX410"></A>True if tinyness is detected before rounding. Other than this description,I don't have a clue what this means; anyone have a copy of IEC 559/IEEE 754floating around? <P><DT><CODE>T traps(T);</CODE><DD><A NAME="IDX411"></A>True if trapping is implemented for this type. <P><DT><CODE>T zero(T);</CODE><DD><A NAME="IDX412"></A>Returns a representation for zero. </DL><P><A NAME="FAQ"></A><HR SIZE="6"><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_10.html#SEC152"> << </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_11.html#SEC155"> >> </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="blitz_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><BR> <FONT SIZE="-1">This document was generatedby <I>Julian Cummings</I> on <I>November, 4 2004</I>using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html"><I>texi2html</I></A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -