#include <iostream>
#include <math.h>

const int intToFloatAndBack( const int intVal )
{
	const float floatVal = static_cast<float>(intVal);
	return static_cast<int>(floatVal);
}

const float floatToIntAndBack(const float floatVal, const int precision = 3 )
{
	const unsigned char power = pow( 10, precision );
	const int intVal = floatVal * power;
	return intVal / static_cast<float>(power);
}

int main ( void )
{
	//Example of saving ints as floats failing
	std::cout << intToFloatAndBack( 123456789 ) << std::endl;

	//Example of saving floats as int succeeding (Will of course fail for some inputs)
	std::cout << floatToIntAndBack( 123.456f ) << std::endl;
	return 0;
}