Using numeric_limits instead of static_cast-hack.