unity round up float code example
Example 1: round to float unity
float f = 3.16856f;
f = Mathf.Round(f * 10.0f) * 0.1f;
float f = 3.16856f;
f = Mathf.Round(f * 100.0f) * 0.01f;
Example 2: unity round
Mathf.Round(10.2f);
Example 3: unity round float to nearest 100
int sayi;
int = ((int)(((int)(sayi/100))*100));
float sayi;
sayi = ((float)(((int)(sayi/100))*100));
int yuvarlama;
int sayi;
int = ((int)(((int)(sayi/yuvarlama))*yuvarlama));
float yuvarlama;
float sayi;
sayi = ((float)(((int)(sayi/yuvarlama))*yuvarlama));
Example 4: how to round to nearest whole number unity
Debug.Log(Mathf.Round(10.0f));
Debug.Log(Mathf.Round(10.2f));
Debug.Log(Mathf.Round(10.7f));