/***************************************************************************** * * numinquire.cpp Blitz++ example, illustrating how to * get at properties of numeric types. * * $Id: numinquire.cpp,v 1.1.1.1 2005/06/15 14:31:20 tveldhui Exp $ * * $Log: numinquire.cpp,v $ * Revision 1.1.1.1 2005/06/15 14:31:20 tveldhui * * * Revision 1.1 1997/07/03 11:54:55 tveldhui * Initial revision * */ #include #include using namespace blitz; int main() { double z = 1.0; cout << "Some inquiries into the nature of double:" << endl << "digits(z) = " << digits(z) << endl << "epsilon(z) = " << epsilon(z) << endl << "huge(z) = " << huge(z) << endl << "tiny(z) = " << tiny(z) << endl << "maxExponent(z) = " << maxExponent(z) << endl << "minExponent(z) = " << minExponent(z) << endl << "maxExponent10(z) = " << maxExponent10(z) << endl << "minExponent10(z) = " << minExponent10(z) << endl << "precision(z) = " << precision(z) << endl << "radix(z) = " << radix(z) << endl; Range r = range(z); cout << "range(z) = [ " << r.first() << ", " << r.last() << " ]" << endl; cout << endl << "More obscure properties:" << endl << "is_signed(z) = " << is_signed(z) << endl << "is_integer(z) = " << is_integer(z) << endl << "is_exact(z) = " << is_exact(z) << endl << "round_error(z) = " << round_error(z) << endl << "has_infinity(z) = " << has_infinity(z) << endl << "has_quiet_NaN(z) = " << has_quiet_NaN(z) << endl << "has_signaling_NaN(z) = " << has_signaling_NaN(z) << endl << "has_denorm(z) = " << has_denorm(z) << endl << "has_denorm_loss(z) = " << has_denorm_loss(z) << endl << "infinity(z) = " << infinity(z) << endl << "quiet_NaN(z) = " << quiet_NaN(z) << endl << "signaling_NaN(z) = " << signaling_NaN(z) << endl << "denorm_min(z) = " << denorm_min(z) << endl << "is_iec559(z) = " << is_iec559(z) << endl << "is_bounded(z) = " << is_bounded(z) << endl << "is_modulo(z) = " << is_modulo(z) << endl << "traps(z) = " << traps(z) << endl << "tinyness_before(z) = " << tinyness_before(z) << endl; return 0; } // Output: Some inquiries into the nature of double: digits(z) = 53 epsilon(z) = 2.22045e-16 huge(z) = 1.79769e+308 tiny(z) = 2.22507e-308 maxExponent(z) = 1024 minExponent(z) = -1021 maxExponent10(z) = 308 minExponent10(z) = -307 precision(z) = 15 radix(z) = 2 range(z) = [ -307, 308 ] More obscure properties: is_signed(z) = 1 is_integer(z) = 0 is_exact(z) = 0 round_error(z) = 0.5 has_infinity(z) = 1 has_quiet_NaN(z) = 1 has_signaling_NaN(z) = 1 has_denorm(z) = 0 has_denorm_loss(z) = 0 infinity(z) = INF quiet_NaN(z) = NaNQ signaling_NaN(z) = NaNS denorm_min(z) = 2.22507e-308 is_iec559(z) = 1 is_bounded(z) = 1 is_modulo(z) = 0 traps(z) = 1 tinyness_before(z) = 1