⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fixed-point.h

📁 著名的数学计算类库
💻 H
字号:
#include <blitz/array.h>#include <blitz/numinquire.h> // for huge()using namespace blitz;// A simple fixed point arithmetic class which represents a point// in the interval [0,1].class FixedPoint {public:	  // The type to use for the mantissa    typedef unsigned int T_mantissa;    FixedPoint() { }    FixedPoint(T_mantissa mantissa)    {          mantissa_ = mantissa;    }    FixedPoint(double value)    {        assert((value >= 0.0) && (value <= 1.0));        mantissa_ = static_cast<T_mantissa>(value * huge(T_mantissa()));    }       FixedPoint operator+(FixedPoint x)    { return FixedPoint(mantissa_ + x.mantissa_); }    double value() const    { return mantissa_ / double(huge(T_mantissa())); }private:    T_mantissa mantissa_;};ostream& operator<<(ostream& os, const FixedPoint& a){    os << a.value();    return os;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -