x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
msvc_rounding_control.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\numeric\interval\detail\msvc_rounding_control.hpp
旋转
特效
属性
历史版本
/* Boost interval/detail/msvc_rounding_control.hpp file * * Copyright 2000 Maarten Keijzer * Copyright 2002 Herv� Br�nnimann, Guillaume Melquiond, Sylvain Pion * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or * copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP #define BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP #ifndef _MSC_VER # error This header is only intended for MSVC, but might work for Borland as well #endif #include
// MSVC rounding control // Although the function is called _control87, it seems to work for // other FPUs too, so it does not have to be changed to _controlfp. namespace boost { namespace numeric { namespace interval_lib { namespace detail { extern "C" { double rint(double); } struct x86_rounding { static unsigned int hard2msvc(unsigned short m) { unsigned int n = 0; if (m & 0x01) n |= _EM_INVALID; if (m & 0x02) n |= _EM_DENORMAL; if (m & 0x04) n |= _EM_ZERODIVIDE; if (m & 0x08) n |= _EM_OVERFLOW; if (m & 0x10) n |= _EM_UNDERFLOW; if (m & 0x20) n |= _EM_INEXACT; switch (m & 0x300) { case 0x000: n |= _PC_24; break; case 0x200: n |= _PC_53; break; case 0x300: n |= _PC_64; break; } switch (m & 0xC00) { case 0x000: n |= _RC_NEAR; break; case 0x400: n |= _RC_DOWN; break; case 0x800: n |= _RC_UP; break; case 0xC00: n |= _RC_CHOP; break; } if (m & 0x1000) n |= _IC_AFFINE; // only useful on 287 return n; } static unsigned short msvc2hard(unsigned int n) { unsigned short m = 0; if (n & _EM_INVALID) m |= 0x01; if (n & _EM_DENORMAL) m |= 0x02; if (n & _EM_ZERODIVIDE) m |= 0x04; if (n & _EM_OVERFLOW) m |= 0x08; if (n & _EM_UNDERFLOW) m |= 0x10; if (n & _EM_INEXACT) m |= 0x20; switch (n & _MCW_RC) { case _RC_NEAR: m |= 0x000; break; case _RC_DOWN: m |= 0x400; break; case _RC_UP: m |= 0x800; break; case _RC_CHOP: m |= 0xC00; break; } switch (n & _MCW_PC) { case _PC_24: m |= 0x000; break; case _PC_53: m |= 0x200; break; case _PC_64: m |= 0x300; break; } if ((n & _MCW_IC) == _IC_AFFINE) m |= 0x1000; return m; } typedef unsigned short rounding_mode; static void get_rounding_mode(rounding_mode& mode) { mode = msvc2hard(_control87(0, 0)); } static void set_rounding_mode(const rounding_mode mode) { _control87(hard2msvc(mode), _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC); } static double to_int(const double& x) { return rint(x); } }; } // namespace detail } // namespace interval_lib } // namespace numeric } // namespace boost #endif /* BOOST_NUMERIC_INTERVAL_DETAIL_MSVC_ROUNDING_CONTROL_HPP */
msvc_rounding_control.hpp
网页地址
文件地址
上一页
9/14
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.