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

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

                Value = (ushort)((value.Value >> 4) + (value.Value & 8));
            }
예제 #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(Float16 value)
 {
     if ((value.Value & ExponentMask) != ExponentMask)
     {
         return(false);
     }
     return((value.Value & MantissaMask) != 0);
 }
예제 #3
0
파일: Constant.cs 프로젝트: tgiphil/reko
 public ConstantReal16(DataType dt, Float16 value)
     : base(dt)
 {
     this.value = value;
 }
예제 #4
0
파일: Constant.cs 프로젝트: tgiphil/reko
 public ConstantReal16(DataType dt, double value)
     : base(dt)
 {
     this.value = new Float16(value);
 }
예제 #5
0
        private string RoundTrip(double d)
        {
            var f16 = new Float16(d);

            return(f16.ToString("G", CultureInfo.InvariantCulture));
        }
예제 #6
0
        private string F16(ushort binary16)
        {
            var f16 = new Float16(binary16);

            return(f16.ToString("G", CultureInfo.InvariantCulture));
        }
예제 #7
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(Float16 value)
 {
     return(value.Value == PositiveInfinity);
 }
예제 #8
0
 /// <summary>
 /// Returns a value indicating whether the specified number evaluates to negative infinity.
 /// </summary>
 /// <param name="value">An instance of this class.</param>
 /// <returns><b>true</b> if <paramref name="value"/> evaluates to <see cref="NegativeInfinity"/>; otherwise, <b>false</b>.</returns>
 public static bool IsNegativeInfinity(Float16 value)
 {
     return(value.Value == NegativeInfinity);
 }
예제 #9
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(Float16 value)
 {
     return((value.Value & (ExponentMask | MantissaMask)) == ExponentMask);
 }
예제 #10
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 Float16(Float16 value)
 {
     Value = value.Value;
 }
예제 #11
0
 /// <summary>Get the squared value of the input.</summary>
 public static Float16 Squared(this Float16 value)
 {
     return((Float16)(value * value));
 }