Beispiel #1
0
        /// <summary>
        /// Constructs an instance of this class with the value of the argument.
        /// </summary>
        /// <param name="value">An instance of <see cref="glFloat16"/>.</param>
        public glUFloat11(glFloat16 value)
        {
            int sig = value.Value & glFloat16.SignMask;
            int exp = value.Value & glFloat16.ExponentMask;
            int man = value.Value & glFloat16.MantissaMask;

            if (exp == glFloat16.ExponentMask)
            {
                if (man != 0)
                {
                    Value = NaN;
                }
                else if (sig == 0)
                {
                    Value = Infinity;
                }
                else
                {
                    Value = 0;
                }
                return;
            }

            Value = (ushort)((value.Value >> 4) + (value.Value & 8));
        }
Beispiel #2
0
 /// <summary>
 /// Returns a value that indicates whether the specified value is not a number (<see cref="NaN"/>).
 /// </summary>
 /// <param name="value">An instance of this class.</param>
 /// <returns><b>true</b> if <paramref name="value"/> evaluates to <see cref="NaN"/>; otherwise, <b>false</b>.</returns>
 public static bool IsNaN(glFloat16 value)
 {
     if ((value.Value & ExponentMask) != ExponentMask)
     {
         return(false);
     }
     return((value.Value & MantissaMask) != 0);
 }
Beispiel #3
0
 /// <summary>
 /// Returns a value indicating whether the specified number evaluates to positive infinity.
 /// </summary>
 /// <param name="value">An instance of this class.</param>
 /// <returns><b>true</b> if <paramref name="value"/> evaluates to <see cref="PositiveInfinity"/>; otherwise, <b>false</b>.</returns>
 public static bool IsPositiveInfinity(glFloat16 value)
 {
     return(value.Value == PositiveInfinity);
 }
Beispiel #4
0
 /// <summary>
 /// Returns a value indicating whether the specified number evaluates to negative or positive infinity.
 /// </summary>
 /// <param name="value">An instance of this class.</param>
 /// <returns><b>true</b> if <paramref name="value"/> evaluates to <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/>; otherwise, <b>false</b>.</returns>
 public static bool IsInfinity(glFloat16 value)
 {
     return((value.Value & (ExponentMask | MantissaMask)) == ExponentMask);
 }
Beispiel #5
0
 /// <summary>
 /// Constructs an instance of this class with the value of the argument.
 /// </summary>
 /// <param name="value">An instance of this class.</param>
 public glFloat16(glFloat16 value)
 {
     Value = value.Value;
 }