diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-09 21:36:34 -0200 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-09 21:36:34 -0200 |
commit | 5c26dd04dd171112d14bfb24db96cf286566e19b (patch) | |
tree | 62a2dd9370a54968bf543344153ef69a85561840 /utils.h | |
parent | 886bdd0fa43a2fcdeca306648b643b623af99f88 (diff) |
Slightly reworked rewinding; added values rewinding.
Needs a solution to the problem of which values must be displayed
and/or interpolated. Currently, whenever the user rewinds, the
current error measure is displayed, regardless of what was being
displayed before. This will probably be trivial to solve once we
have a nice way of changing the current measure.
* Also changed all OpenMP-powered for loops to use signed integers,
requirements of OMP2.x (which is what MSVC supports currently)
* The above change comes with a new header for utility functions
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -0,0 +1,19 @@ +#include <limits> +#include <stdexcept> + +/* + * Credits to: + * http://stackoverflow.com/questions/13150449/efficient-unsigned-to-signed-cast-avoiding-implementation-defined-behavior + */ +template<typename Uint, typename Int> +Int uintToInt(Uint x) +{ + if (x <= std::numeric_limits<Int>::max()) + return static_cast<Int>(x); + + if (x >= std::numeric_limits<Int>::min()) + return static_cast<Int>(x - std::numeric_limits<Int>::min()) + + std::numeric_limits<Int>::min(); + + throw std::overflow_error("given value does not fit integer type"); +} |