public CeilToPrecision ( float x, int precision = 1 ) : int | ||
x | float | input |
precision | int | number of digits to preserve past the magnitude, should be equal to or greater than zero. |
Результат | int |
public int CeilToPrecision( float x, int precision = 1)
{
int magnitude = Mathf.FloorToInt( Mathf.Log10( x ) );
int unit = Mathf.FloorToInt( Mathf.Pow( 10, magnitude - precision ) );
return Mathf.CeilToInt(x / unit) * unit;
}