📄 fnconst.hpp
字号:
// Pi implementation -*- C++ -*-//// Copyright (C) 2005 Ben T. Bear//// This file is published under GNU GPL 2.0. See more in "copy.hpp".// #include "copy.hpp"#ifndef __bt2il_fn_const_hpp#define __bt2il_fn_const_hpp#include "fn.hpp"#include "fnmath.hpp"#include "fnexp.hpp"namespace btil{ namespace fn { struct pi; struct e; struct one; struct two; struct three; struct ten; struct sqrt_two; struct sqrt_three; struct ln_two; struct ln_ten; struct lg_e; struct one { static const double f_val = 1.0; }; struct two { static const double f_val = 2.0; }; struct three { static const double f_val = 3.0; }; struct ten { static const double f_val = 10.0; }; struct ln_ten { static const double f_val = __ln_ten::f_val; }; struct lg_e { static const double f_val = __lg_e::f_val; }; struct sqrt_two { static const double f_val = sqrt<two>::value::f_val; }; struct sqrt_three { static const double f_val = sqrt<three>::value::f_val; }; struct ln_two { static const double f_val = __ln2::f_val; }; template <int n> struct __pi_item; template <> struct __pi_item<0> { static const double item = 0.0; static const double pi_n = 2.0; }; template <int n> struct __pi_item { static const double a = 2.0 + __pi_item<n-1>::item; static const double x0 = 2.0; static const double x1 = (a / x0 + x0) / 2.0; static const double x2 = (a / x1 + x1) / 2.0; static const double x3 = (a / x2 + x2) / 2.0; static const double x4 = (a / x3 + x3) / 2.0; static const double x5 = (a / x4 + x4) / 2.0; static const double x6 = (a / x5 + x5) / 2.0; static const double x7 = (a / x6 + x6) / 2.0; static const double x8 = (a / x7 + x7) / 2.0; static const double x = x8; static const double item = x; static const double pi_n = __pi_item<n-1>::pi_n * 2.0 / x; }; struct pi { static const double f_val = __pi_item<35>::pi_n; }; struct e { static const double f_val = __e::f_val; }; }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -