Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Floating-Point Constant Macros

Boost , Math Toolkit 2.5.0 , Chapter 3. Specified-width floating-point typedefs

Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Все макросы типа<BOOST_FLOAT16_C,BOOST_FLOAT32_C,BOOST_FLOAT64_C,BOOST_FLOAT80_C,BOOST_FLOAT128_C,>и<BOOST_FLOATMAX_C>всегда определяются после включения<<boost/cstdfloat.hpp>>.

Они позволяют заявлять константы плавающей точкипо меньшей мере указанной ширины:

// Declare Archimedes' constant using float32_t with approximately 7 decimal digits of precision.
static const boost::float32_t pi = BOOST_FLOAT32_C(3.1415926536);
// Declare the Euler-gamma constant with approximately 15 decimal digits of precision.
static const boost::float64_t euler =
   BOOST_FLOAT64_C(0.57721566490153286060651209008240243104216);
// Declare the Golden Ratio constant with the maximum decimal digits of precision that the platform supports.
static const boost::floatmax_t golden_ratio =
   BOOST_FLOATMAX_C(1.61803398874989484820458683436563811772);
[Tip] Tip

Повышаю. Математика обеспечивает множество констант «встроенных», поэтому всегда используйте Boost. Константы математики, если таковые имеются, например:

// Display the constant pi to the maximum available precision.
  boost::floatmax_t pi_max = boost::math::constants::pi<boost::floatmax_t>();
  std::cout.precision(std::numeric_limits<boost::floatmax_t>::digits10);
  std::cout << "Most precise pi = "  << pi_max << std::endl;
// If floatmax_t is float_128_t, then
// Most precise pi = 3.141592653589793238462643383279503

cstdfloat_example.cpp.

См. полный списокконстант.


PrevUpHomeNext

Статья Floating-Point Constant Macros раздела Math Toolkit 2.5.0 Chapter 3. Specified-width floating-point typedefs может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: Chapter 3. Specified-width floating-point typedefs ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-20 01:30:54/0.0052320957183838/1