2010-12-03から1日間の記事一覧

負の整数での除算と剰余を指定した挙動で

C++

C++03では、左右両方のオペランドが正でないときは/や%の挙動が実装依存になるので、指定した挙動での除算と剰余を求める関数(+alpha)を作ってる。hwm/arithmetic.hpp #ifndef HWM_ARITHMETIC_HPP #define HWM_ARITHMETIC_HPP #include <cmath> #include <boost/assert.hpp> #include <boost/mpl/and.hpp></boost/mpl/and.hpp></boost/assert.hpp></cmath>…