now using template independent type casting for math functions!