/// <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)); }
/// <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); }
public ConstantReal16(DataType dt, Float16 value) : base(dt) { this.value = value; }
public ConstantReal16(DataType dt, double value) : base(dt) { this.value = new Float16(value); }
private string RoundTrip(double d) { var f16 = new Float16(d); return(f16.ToString("G", CultureInfo.InvariantCulture)); }
private string F16(ushort binary16) { var f16 = new Float16(binary16); return(f16.ToString("G", CultureInfo.InvariantCulture)); }
/// <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); }
/// <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); }
/// <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); }
/// <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; }
/// <summary>Get the squared value of the input.</summary> public static Float16 Squared(this Float16 value) { return((Float16)(value * value)); }