#ifndef FBASICS_CASTS_H #define FBASICS_CASTS_H #include namespace NICE { /// round_to_nearest_cast: cast to the nearest value in the target domain template Target round_to_nearest_cast(Source x); // Allg. round - functor template struct roundToNearest { static Target cast(Source x) { return static_cast(x); } }; // Part. spezialisiert template struct roundToNearest { static long long cast(Source x) { return static_cast(floor(x+0.5)); } }; template struct roundToNearest { static unsigned long long cast(Source x) { return static_cast(x+0.5); } }; template struct roundToNearest { static long cast(Source x) { return static_cast(floor(x+0.5)); } }; template struct roundToNearest { static unsigned long cast(Source x) { return static_cast(x+0.5); } }; template struct roundToNearest { static int cast(Source x) { return static_cast(floor(x+0.5)); } }; template struct roundToNearest { static unsigned int cast(Source x) { return static_cast(x+0.5); } }; template struct roundToNearest { static char cast(Source x) { return static_cast(floor(x+0.5)); } }; template struct roundToNearest { static unsigned char cast(Source x) { return static_cast(x+0.5); } }; template Target round_to_nearest_cast(Source x) { return roundToNearest::cast(x); } } // namespace NICE #endif // FBASICS_CASTS_H