Ticket #2390: floating_point_comparison.hpp.diff
File floating_point_comparison.hpp.diff, 1.6 KB (added by , 14 years ago) |
---|
-
boost/test/floating_point_comparison.hpp
79 79 safe_fpt_division( FPT f1, FPT f2 ) 80 80 { 81 81 // Avoid overflow. 82 if( f2 < static_cast<FPT>(1) && f1 > f2*fpt_limits<FPT>::max_value() )82 if( (f2 < static_cast<FPT>(1)) && (f1 > f2*fpt_limits<FPT>::max_value()) ) 83 83 return fpt_limits<FPT>::max_value(); 84 84 85 85 // Avoid underflow. 86 if( f1 == static_cast<FPT>(0) ||87 f2 > static_cast<FPT>(1) && f1 < f2*fpt_limits<FPT>::min_value() )86 if( (f1 == static_cast<FPT>(0)) || 87 ((f2 > static_cast<FPT>(1)) && (f1 < f2*fpt_limits<FPT>::min_value())) ) 88 88 return static_cast<FPT>(0); 89 89 90 90 return f1/f2; 91 91 } 92 92 93 // helper templates to prevent ODR violations 94 template<class T> 95 struct static_constant { 96 static T value; 97 }; 98 99 template<class T> 100 T static_constant<T>::value; 101 93 102 //____________________________________________________________________________// 94 103 95 104 } // namespace tt_detail … … 221 230 }; 222 231 223 232 namespace { 224 c heck_is_close_t check_is_close;233 const check_is_close_t& check_is_close = tt_detail::static_constant<check_is_close_t>::value; 225 234 } 226 235 227 236 //____________________________________________________________________________// … … 243 252 }; 244 253 245 254 namespace { 246 c heck_is_small_t check_is_small;255 const check_is_small_t& check_is_small = tt_detail::static_constant<check_is_small_t>::value; 247 256 } 248 257 249 258 //____________________________________________________________________________//