I am calculating time which is float in variable, I am then converting the float to only 2 decimal points and then passing it to a string variable. I however do not require converting the float to decimal points, instead round up the float to integer. How do I achieve this?
That is for example, if timer is > 26.50f, then final timer should be 27.
Also, can we manually set the threshold? The threshold being values after the decimal point? And then the script decides which number the integer belongs to? For example, I set the threshold as .25 till .99
float 1 = 23.26 = 24
float 2 = 17.25 = 18
float 3 = 19.24 = 19
public float timer;
public string timer_string;
void Update()
{
timer += Time.deltaTime;
timer_string = timer.ToString("F2"); //decimal upto 2 places
timer_string = timer.ToString("F0"); //is this the way? Since it does not round up
}