UnityEngine.Mathf.Pow C# (CSharp) Method

Pow() public static method

public static Pow ( float f, float p ) : float
f float
p float
return float
        public static float Pow(float f, float p)
        {
            return (float)Math.Pow(f, p);
        }

Usage Example

コード例 #1
0
        private ushort GetUShortUnsignedFloatSmallerThan512(float floatVal)
        {
            if (floatVal < 0 || floatVal > 512)
            {
                throw new FormatException($"Error, can only represent values in the following ranges: 0 <= x <= 512, value given: {floatVal}");
            }

            ushort ushortVal = 0;

            for (sbyte bitIndex = 15; bitIndex >= 0; bitIndex--)
            {
                float takeAway = Mathf.Pow(2f, bitIndex - 7);
                float newVal   = floatVal - takeAway;

                if (newVal < 0)
                {
                    continue;
                }

                ushort bitValue = (ushort)Mathf.Pow(2f, bitIndex);
                ushortVal += bitValue;

                floatVal = newVal;
            }

            return(ushortVal);
        }
All Usage Examples Of UnityEngine.Mathf::Pow