UnityEditor.MathUtils.GetNumberOfDecimalsForMinimumDifference C# (CSharp) Method

GetNumberOfDecimalsForMinimumDifference() static private method

static private GetNumberOfDecimalsForMinimumDifference ( double minDifference ) : int
minDifference double
return int
        internal static int GetNumberOfDecimalsForMinimumDifference(double minDifference)
        {
            return (int) Math.Max(0.0, -Math.Floor(Math.Log10(Math.Abs(minDifference))));
        }

Same methods

MathUtils::GetNumberOfDecimalsForMinimumDifference ( float minDifference ) : int

Usage Example

示例#1
0
        public string FormatTime(float time, float frameRate, TimeFormat timeFormat)
        {
            if (timeFormat == TimeFormat.None)
            {
                int numberOfDecimalsForMinimumDifference;
                if (frameRate != 0f)
                {
                    numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference((float)(1f / frameRate));
                }
                else
                {
                    numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference((float)(base.shownArea.width / base.drawRect.width));
                }
                return(time.ToString("N" + numberOfDecimalsForMinimumDifference));
            }
            int num2 = Mathf.RoundToInt(time * frameRate);

            if (timeFormat == TimeFormat.TimeFrame)
            {
                int    num4   = (int)frameRate;
                int    length = num4.ToString().Length;
                string str2   = string.Empty;
                if (num2 < 0)
                {
                    str2 = "-";
                    num2 = -num2;
                }
                int   num5 = num2 / ((int)frameRate);
                float num6 = ((float)num2) % frameRate;
                return(str2 + num5.ToString() + ":" + num6.ToString().PadLeft(length, '0'));
            }
            return(num2.ToString());
        }
All Usage Examples Of UnityEditor.MathUtils::GetNumberOfDecimalsForMinimumDifference