Round To Float Unity

[Solved] Round To Float Unity | Csharp - Code Explorer | yomemimo.com
Question : round to float unity

Answered by : comfortable-caterpillar-i6i9x3xhv978

float f = 3.16856f;
f = Mathf.Round(f * 10.0f) * 0.1f;
//Which will give 3.2f
//If you want 2 decimal points then,
float f = 3.16856f;
f = Mathf.Round(f * 100.0f) * 0.01f;
//Which results in 3.17f, and so on.

Source : | Last Update : Sat, 01 Aug 20

Question : unity round float to nearest 10

Answered by : remzi

//int
int sayi;
int = ((int)(((int)(sayi/10))*10));
//float
float sayi;
sayi = ((float)(((int)(sayi/10))*10));

Source : | Last Update : Fri, 22 Jan 21

Answers related to round to float unity

Code Explorer Popular Question For Csharp