Skip to content

Instantly share code, notes, and snippets.

@kirillrybin
Last active August 29, 2015 14:05
Show Gist options
  • Save kirillrybin/f891877fdae5e66a6e32 to your computer and use it in GitHub Desktop.
Save kirillrybin/f891877fdae5e66a6e32 to your computer and use it in GitHub Desktop.
how to round a float to 2 DP
public static float Round(float value, int digits)
{
float mult = Mathf.Pow(10.0f, (float)digits);
return Mathf.Round(value * mult) / mult;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment