Changeset 1053
- Timestamp:
- 12/27/20 19:35:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd_math.h
r979 r1053 78 78 void fpExceptDisable(); 79 79 80 // std::lerp can be used since c++20 (and has some guaranteed properties probably better than this basic formula) but apparently it is not a template80 // std::lerp can be used since C++20 (and has some guaranteed properties probably better than this basic formula) but apparently it is not a template 81 81 template <typename Value, typename Linear> Value universal_lerp(Value a,Value b,Linear t) {return a*(1-t)+b*t;} 82 82 … … 86 86 } 87 87 88 //in C++20, related: https://en.cppreference.com/w/cpp/numeric/countl_zero 89 #ifdef _WIN32 //visual studio is missing ffs() 90 static inline unsigned ffs(int x) 91 { 92 if (x == 0) return 0u; 93 unsigned r = 1; 94 while ((x & 1) == 0) 95 x >>= 1, ++r; 96 return r; 97 } 88 98 #endif 99 100 101 #endif
Note: See TracChangeset
for help on using the changeset viewer.