31 instantiations of BFloat16
System.Private.CoreLib (31)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (2)
953
internal static BFloat16 Int16BitsToBFloat16(short value) => new
BFloat16
((ushort)(value));
1011
internal static BFloat16 UInt16BitsToBFloat16(ushort value) => new
BFloat16
(value);
src\libraries\System.Private.CoreLib\src\System\Numerics\BFloat16.cs (29)
86
public static BFloat16 Epsilon => new
BFloat16
(EpsilonBits);
88
public static BFloat16 PositiveInfinity => new
BFloat16
(PositiveInfinityBits);
90
public static BFloat16 NegativeInfinity => new
BFloat16
(NegativeInfinityBits);
92
public static BFloat16 NaN => new
BFloat16
(NegativeQNaNBits);
95
public static BFloat16 MinValue => new
BFloat16
(MinValueBits);
98
public static BFloat16 MaxValue => new
BFloat16
(MaxValueBits);
509
return new
BFloat16
((ushort)bitValue);
556
return new
BFloat16
((ushort)(roundedValueBits >> 16));
598
return new
BFloat16
((ushort)(!float.IsNaN(value) ? roundedBits : (bits >> 16)));
617
return new
BFloat16
((ushort)(roundedValueBits >> 16));
861
static BFloat16 IAdditiveIdentity<BFloat16, BFloat16>.AdditiveIdentity => new
BFloat16
(PositiveZeroBits);
868
static BFloat16 IBinaryNumber<BFloat16>.AllBitsSet => new
BFloat16
(0xFFFF);
909
return new
BFloat16
((ushort)(left._value & right._value));
915
return new
BFloat16
((ushort)(left._value | right._value));
921
return new
BFloat16
((ushort)(left._value ^ right._value));
927
return new
BFloat16
((ushort)(~value._value));
1079
public static BFloat16 E => new
BFloat16
(EBits);
1082
public static BFloat16 Pi => new
BFloat16
(PiBits);
1085
public static BFloat16 Tau => new
BFloat16
(TauBits);
1092
public static BFloat16 NegativeZero => new
BFloat16
(NegativeZeroBits);
1130
return new
BFloat16
((ushort)bits);
1163
return new
BFloat16
((ushort)bits);
1283
public static BFloat16 MultiplicativeIdentity => new
BFloat16
(PositiveOneBits);
1309
return new
BFloat16
((ushort)((xbits & ~SignMask) | (ybits & SignMask)));
1387
public static BFloat16 One => new
BFloat16
(PositiveOneBits);
1393
public static BFloat16 Zero => new
BFloat16
(PositiveZeroBits);
1396
public static BFloat16 Abs(BFloat16 value) => new
BFloat16
((ushort)(value._value & ~SignMask));
1979
public static BFloat16 NegativeOne => new
BFloat16
(NegativeOneBits);
2148
static BFloat16 IBinaryFloatParseAndFormatInfo<BFloat16>.BitsToFloat(ulong bits) => new
BFloat16
((ushort)(bits));
633 references to BFloat16
System.Private.CoreLib (591)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (4)
951
internal static short BFloat16BitsToInt16(
BFloat16
value) => (short)value._value;
953
internal static
BFloat16
Int16BitsToBFloat16(short value) => new BFloat16((ushort)(value));
1009
internal static ushort BFloat16BitsToUInt16(
BFloat16
value) => value._value;
1011
internal static
BFloat16
UInt16BitsToBFloat16(ushort value) => new BFloat16(value);
src\libraries\System.Private.CoreLib\src\System\Numerics\BFloat16.cs (587)
20
IComparable<
BFloat16
>,
21
IEquatable<
BFloat16
>,
22
IBinaryFloatingPointIeee754<
BFloat16
>,
23
IMinMaxValue<
BFloat16
>,
25
IBinaryFloatParseAndFormatInfo<
BFloat16
>
86
public static
BFloat16
Epsilon => new BFloat16(EpsilonBits);
88
public static
BFloat16
PositiveInfinity => new BFloat16(PositiveInfinityBits);
90
public static
BFloat16
NegativeInfinity => new BFloat16(NegativeInfinityBits);
92
public static
BFloat16
NaN => new BFloat16(NegativeQNaNBits);
95
public static
BFloat16
MinValue => new BFloat16(MinValueBits);
98
public static
BFloat16
MaxValue => new BFloat16(MaxValueBits);
153
public static bool IsFinite(
BFloat16
value)
161
public static bool IsInfinity(
BFloat16
value)
169
public static bool IsNaN(
BFloat16
value)
176
internal static bool IsNaNOrZero(
BFloat16
value)
184
public static bool IsNegative(
BFloat16
value)
191
public static bool IsNegativeInfinity(
BFloat16
value)
199
public static bool IsNormal(
BFloat16
value)
207
public static bool IsPositiveInfinity(
BFloat16
value)
215
public static bool IsSubnormal(
BFloat16
value)
222
public static bool IsZero(
BFloat16
value)
229
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> in the default parse style.
232
/// <returns>The equivalent <see cref="
BFloat16
"/> value representing the input string. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
233
public static
BFloat16
Parse(string s) => Parse(s, DefaultParseStyle, provider: null);
236
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> in the given <see cref="NumberStyles"/>.
240
/// <returns>The equivalent <see cref="
BFloat16
"/> value representing the input string. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
241
public static
BFloat16
Parse(string s, NumberStyles style) => Parse(s, style, provider: null);
244
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> and <see cref="IFormatProvider"/>.
248
/// <returns>The equivalent <see cref="
BFloat16
"/> value representing the input string. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
249
public static
BFloat16
Parse(string s, IFormatProvider? provider) => Parse(s, DefaultParseStyle, provider);
252
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
257
/// <returns>The equivalent <see cref="
BFloat16
"/> value representing the input string. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
258
public static
BFloat16
Parse(string s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null)
268
/// Parses a <see cref="
BFloat16
"/> from a <see cref="ReadOnlySpan{Char}"/> and <see cref="IFormatProvider"/>.
273
/// <returns>The equivalent <see cref="
BFloat16
"/> value representing the input string. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns>
274
public static
BFloat16
Parse(ReadOnlySpan<char> s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null)
277
return Number.ParseFloat<char,
BFloat16
>(s, style, NumberFormatInfo.GetInstance(provider));
281
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="string"/> in the default parse style.
284
/// <param name="result">The equivalent <see cref="
BFloat16
"/> value representing the input string if the parse was successful. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
BFloat16
"/> value is returned.</param>
286
public static bool TryParse([NotNullWhen(true)] string? s, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider: null, out result);
289
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="ReadOnlySpan{Char}"/> in the default parse style.
292
/// <param name="result">The equivalent <see cref="
BFloat16
"/> value representing the input string if the parse was successful. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
BFloat16
"/> value is returned.</param>
294
public static bool TryParse(ReadOnlySpan<char> s, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider: null, out result);
296
/// <summary>Tries to convert a UTF-8 character span containing the string representation of a number to its <see cref="
BFloat16
"/> number equivalent.</summary>
298
/// <param name="result">When this method returns, contains a <see cref="
BFloat16
"/> number equivalent of the numeric value or symbol contained in <paramref name="utf8Text" /> if the conversion succeeded or zero if the conversion failed. The conversion fails if the <paramref name="utf8Text" /> is <see cref="ReadOnlySpan{T}.Empty" /> or is not in a valid format. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.</param>
300
public static bool TryParse(ReadOnlySpan<byte> utf8Text, out
BFloat16
result) => TryParse(utf8Text, DefaultParseStyle, provider: null, out result);
303
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
308
/// <param name="result">The equivalent <see cref="
BFloat16
"/> value representing the input string if the parse was successful. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
BFloat16
"/> value is returned.</param>
310
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out
BFloat16
result)
323
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="ReadOnlySpan{Char}"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
328
/// <param name="result">The equivalent <see cref="
BFloat16
"/> value representing the input string if the parse was successful. If the input exceeds BFloat16's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="
BFloat16
"/> value is returned.</param>
330
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out
BFloat16
result)
342
/// <exception cref="ArgumentException">Thrown when <paramref name="obj"/> is not of type <see cref="
BFloat16
"/>.</exception>
345
if (obj is not
BFloat16
other)
356
public int CompareTo(
BFloat16
other) => ((float)this).CompareTo((float)other);
359
public static bool operator ==(
BFloat16
left,
BFloat16
right) => (float)left == (float)right;
362
public static bool operator !=(
BFloat16
left,
BFloat16
right) => (float)left != (float)right;
365
public static bool operator <(
BFloat16
left,
BFloat16
right) => (float)left < (float)right;
368
public static bool operator >(
BFloat16
left,
BFloat16
right) => (float)left > (float)right;
371
public static bool operator <=(
BFloat16
left,
BFloat16
right) => (float)left <= (float)right;
374
public static bool operator >=(
BFloat16
left,
BFloat16
right) => (float)left >= (float)right;
381
public bool Equals(
BFloat16
other) => ((float)this).Equals((float)other);
386
public override bool Equals(object? obj) => obj is
BFloat16
other && Equals(other);
445
/// <summary>Explicitly converts a <see cref="char" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
447
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
448
public static explicit operator
BFloat16
(char value) => (
BFloat16
)(float)value;
450
/// <summary>Explicitly converts a <see cref="decimal" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
452
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
453
public static explicit operator
BFloat16
(decimal value) => (
BFloat16
)(float)value;
455
/// <summary>Explicitly converts a <see cref="double" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
457
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
458
public static explicit operator
BFloat16
(double value)
537
private static unsafe
BFloat16
RoundFromSigned<TInteger>(TInteger value)
559
/// <summary>Explicitly converts a <see cref="short" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
561
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
562
public static explicit operator
BFloat16
(short value) => (
BFloat16
)(float)value;
564
/// <summary>Explicitly converts a <see cref="Half" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
566
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
567
public static explicit operator
BFloat16
(Half value) => (
BFloat16
)(float)value;
569
/// <summary>Explicitly converts a <see cref="int" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
571
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
572
public static explicit operator
BFloat16
(int value) => RoundFromSigned(value);
574
/// <summary>Explicitly converts a <see cref="long" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
576
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
577
public static explicit operator
BFloat16
(long value) => RoundFromSigned(value);
579
/// <summary>Explicitly converts a <see cref="Int128" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
581
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
582
public static explicit operator
BFloat16
(Int128 value) => RoundFromSigned(value);
584
/// <summary>Explicitly converts a <see cref="nint" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
586
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
587
public static explicit operator
BFloat16
(nint value) => RoundFromSigned(value);
589
/// <summary>Explicitly converts a <see cref="float" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
591
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
592
public static explicit operator
BFloat16
(float value)
601
private static unsafe
BFloat16
RoundFromUnsigned<TInteger>(TInteger value)
620
/// <summary>Explicitly converts a <see cref="ushort" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
622
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
624
public static explicit operator
BFloat16
(ushort value) => (
BFloat16
)(float)value;
626
/// <summary>Explicitly converts a <see cref="uint" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
628
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
630
public static explicit operator
BFloat16
(uint value) => RoundFromUnsigned(value);
632
/// <summary>Explicitly converts a <see cref="ulong" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
634
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
636
public static explicit operator
BFloat16
(ulong value) => RoundFromUnsigned(value);
638
/// <summary>Explicitly converts a <see cref="nuint" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
640
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
642
public static explicit operator
BFloat16
(nuint value) => RoundFromUnsigned(value);
644
/// <summary>Explicitly converts a <see cref="UInt128" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
646
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
648
public static explicit operator
BFloat16
(UInt128 value) => RoundFromUnsigned(value);
654
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="byte" /> value.</summary>
657
public static explicit operator byte(
BFloat16
value) => (byte)(float)value;
659
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="byte" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
663
public static explicit operator checked byte(
BFloat16
value) => checked((byte)(float)value);
665
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="char" /> value.</summary>
668
public static explicit operator char(
BFloat16
value) => (char)(float)value;
670
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="char" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
674
public static explicit operator checked char(
BFloat16
value) => checked((char)(float)value);
676
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="decimal" /> value.</summary>
679
public static explicit operator decimal(
BFloat16
value) => (decimal)(float)value;
681
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="short" /> value.</summary>
684
public static explicit operator short(
BFloat16
value) => (short)(float)value;
686
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="short" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
690
public static explicit operator checked short(
BFloat16
value) => checked((short)(float)value);
692
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="int" /> value.</summary>
695
public static explicit operator int(
BFloat16
value) => (int)(float)value;
697
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="int" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
701
public static explicit operator checked int(
BFloat16
value) => checked((int)(float)value);
703
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="long" /> value.</summary>
706
public static explicit operator long(
BFloat16
value) => (long)(float)value;
708
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="long" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
712
public static explicit operator checked long(
BFloat16
value) => checked((long)(float)value);
714
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="Int128"/>.</summary>
717
public static explicit operator Int128(
BFloat16
value) => (Int128)(double)(value);
719
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="Int128"/>, throwing an overflow exception for any values that fall outside the representable range.</summary>
723
public static explicit operator checked Int128(
BFloat16
value) => checked((Int128)(double)(value));
725
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="IntPtr" /> value.</summary>
728
public static explicit operator nint(
BFloat16
value) => (nint)(float)value;
730
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="IntPtr" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
734
public static explicit operator checked nint(
BFloat16
value) => checked((nint)(float)value);
736
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="sbyte" /> value.</summary>
740
public static explicit operator sbyte(
BFloat16
value) => (sbyte)(float)value;
742
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="sbyte" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
747
public static explicit operator checked sbyte(
BFloat16
value) => checked((sbyte)(float)value);
749
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="ushort" /> value.</summary>
753
public static explicit operator ushort(
BFloat16
value) => (ushort)(float)value;
755
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="ushort" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
760
public static explicit operator checked ushort(
BFloat16
value) => checked((ushort)(float)value);
762
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="uint" /> value.</summary>
766
public static explicit operator uint(
BFloat16
value) => (uint)(float)value;
768
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="uint" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
773
public static explicit operator checked uint(
BFloat16
value) => checked((uint)(float)value);
775
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="ulong" /> value.</summary>
779
public static explicit operator ulong(
BFloat16
value) => (ulong)(float)value;
781
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="ulong" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
786
public static explicit operator checked ulong(
BFloat16
value) => checked((ulong)(float)value);
788
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="UInt128"/>.</summary>
792
public static explicit operator UInt128(
BFloat16
value) => (UInt128)(double)(value);
794
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="UInt128"/>, throwing an overflow exception for any values that fall outside the representable range.</summary>
799
public static explicit operator checked UInt128(
BFloat16
value) => checked((UInt128)(double)(value));
801
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="UIntPtr" /> value.</summary>
805
public static explicit operator nuint(
BFloat16
value) => (nuint)(float)value;
807
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="UIntPtr" /> value, throwing an overflow exception for any values that fall outside the representable range.</summary>
812
public static explicit operator checked nuint(
BFloat16
value) => checked((nuint)(float)value);
814
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="Half" /> value.</summary>
817
public static explicit operator Half(
BFloat16
value) => (Half)(float)value;
823
/// <summary>Implicitly converts a <see cref="byte" /> value to its nearest representable <see cref="
BFloat16
" /> value.</summary>
825
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
" /> value.</returns>
826
public static implicit operator
BFloat16
(byte value) => (
BFloat16
)(float)value;
828
/// <summary>Implicitly converts a <see cref="sbyte" /> value to its nearest representable <see cref="
BFloat16
" /> value.</summary>
830
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
" /> value.</returns>
832
public static implicit operator
BFloat16
(sbyte value) => (
BFloat16
)(float)value;
838
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="float"/> value.</summary>
842
public static explicit operator float(
BFloat16
value) => BitConverter.Int32BitsToSingle(value._value << 16);
844
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="double"/> value.</summary>
847
public static explicit operator double(
BFloat16
value) => (double)(float)value;
854
public static
BFloat16
operator +(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left + (float)right);
861
static
BFloat16
IAdditiveIdentity<
BFloat16
,
BFloat16
>.AdditiveIdentity => new BFloat16(PositiveZeroBits);
868
static
BFloat16
IBinaryNumber<
BFloat16
>.AllBitsSet => new BFloat16(0xFFFF);
871
public static bool IsPow2(
BFloat16
value)
900
public static
BFloat16
Log2(
BFloat16
value) => (
BFloat16
)float.Log2((float)value);
907
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator &(
BFloat16
left,
BFloat16
right)
913
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator |(
BFloat16
left,
BFloat16
right)
919
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator ^(
BFloat16
left,
BFloat16
right)
925
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator ~(
BFloat16
value)
935
public static
BFloat16
operator --(
BFloat16
value)
939
return (
BFloat16
)tmp;
947
public static
BFloat16
operator /(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left / (float)right);
954
public static
BFloat16
Exp(
BFloat16
x) => (
BFloat16
)float.Exp((float)x);
957
public static
BFloat16
ExpM1(
BFloat16
x) => (
BFloat16
)float.ExpM1((float)x);
960
public static
BFloat16
Exp2(
BFloat16
x) => (
BFloat16
)float.Exp2((float)x);
963
public static
BFloat16
Exp2M1(
BFloat16
x) => (
BFloat16
)float.Exp2M1((float)x);
966
public static
BFloat16
Exp10(
BFloat16
x) => (
BFloat16
)float.Exp10((float)x);
969
public static
BFloat16
Exp10M1(
BFloat16
x) => (
BFloat16
)float.Exp10M1((float)x);
976
public static
BFloat16
Ceiling(
BFloat16
x) => (
BFloat16
)float.Ceiling((float)x);
979
public static
BFloat16
Floor(
BFloat16
x) => (
BFloat16
)float.Floor((float)x);
982
public static
BFloat16
Round(
BFloat16
x) => (
BFloat16
)float.Round((float)x);
985
public static
BFloat16
Round(
BFloat16
x, int digits) => (
BFloat16
)float.Round((float)x, digits);
988
public static
BFloat16
Round(
BFloat16
x, MidpointRounding mode) => (
BFloat16
)float.Round((float)x, mode);
991
public static
BFloat16
Round(
BFloat16
x, int digits, MidpointRounding mode) => (
BFloat16
)float.Round((float)x, digits, mode);
994
public static
BFloat16
Truncate(
BFloat16
x) => (
BFloat16
)float.Truncate((float)x);
997
int IFloatingPoint<
BFloat16
>.GetExponentByteCount() => sizeof(sbyte);
1000
int IFloatingPoint<
BFloat16
>.GetExponentShortestBitLength()
1015
int IFloatingPoint<
BFloat16
>.GetSignificandByteCount() => sizeof(ushort);
1018
int IFloatingPoint<
BFloat16
>.GetSignificandBitLength() => SignificandLength;
1021
bool IFloatingPoint<
BFloat16
>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten)
1035
bool IFloatingPoint<
BFloat16
>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten)
1049
bool IFloatingPoint<
BFloat16
>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten)
1062
bool IFloatingPoint<
BFloat16
>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten)
1079
public static
BFloat16
E => new BFloat16(EBits);
1082
public static
BFloat16
Pi => new BFloat16(PiBits);
1085
public static
BFloat16
Tau => new BFloat16(TauBits);
1092
public static
BFloat16
NegativeZero => new BFloat16(NegativeZeroBits);
1095
public static
BFloat16
Atan2(
BFloat16
y,
BFloat16
x) => (
BFloat16
)float.Atan2((float)y, (float)x);
1098
public static
BFloat16
Atan2Pi(
BFloat16
y,
BFloat16
x) => (
BFloat16
)float.Atan2Pi((float)y, (float)x);
1101
public static
BFloat16
BitDecrement(
BFloat16
x)
1134
public static
BFloat16
BitIncrement(
BFloat16
x)
1167
public static
BFloat16
FusedMultiplyAdd(
BFloat16
left,
BFloat16
right,
BFloat16
addend) => (
BFloat16
)float.FusedMultiplyAdd((float)left, (float)right, (float)addend);
1170
public static
BFloat16
Ieee754Remainder(
BFloat16
left,
BFloat16
right) => (
BFloat16
)float.Ieee754Remainder((float)left, (float)right);
1173
public static int ILogB(
BFloat16
x)
1201
public static
BFloat16
Lerp(
BFloat16
value1,
BFloat16
value2,
BFloat16
amount) => (
BFloat16
)float.Lerp((float)value1, (float)value2, (float)amount);
1204
public static
BFloat16
ReciprocalEstimate(
BFloat16
x) => (
BFloat16
)float.ReciprocalEstimate((float)x);
1207
public static
BFloat16
ReciprocalSqrtEstimate(
BFloat16
x) => (
BFloat16
)float.ReciprocalSqrtEstimate((float)x);
1210
public static
BFloat16
ScaleB(
BFloat16
x, int n) => (
BFloat16
)float.ScaleB((float)x, n);
1220
public static
BFloat16
Acosh(
BFloat16
x) => (
BFloat16
)float.Acosh((float)x);
1223
public static
BFloat16
Asinh(
BFloat16
x) => (
BFloat16
)float.Asinh((float)x);
1226
public static
BFloat16
Atanh(
BFloat16
x) => (
BFloat16
)float.Atanh((float)x);
1229
public static
BFloat16
Cosh(
BFloat16
x) => (
BFloat16
)float.Cosh((float)x);
1232
public static
BFloat16
Sinh(
BFloat16
x) => (
BFloat16
)float.Sinh((float)x);
1235
public static
BFloat16
Tanh(
BFloat16
x) => (
BFloat16
)float.Tanh((float)x);
1242
public static
BFloat16
operator ++(
BFloat16
value)
1246
return (
BFloat16
)tmp;
1254
public static
BFloat16
Log(
BFloat16
x) => (
BFloat16
)float.Log((float)x);
1257
public static
BFloat16
Log(
BFloat16
x,
BFloat16
newBase) => (
BFloat16
)float.Log((float)x, (float)newBase);
1260
public static
BFloat16
Log10(
BFloat16
x) => (
BFloat16
)float.Log10((float)x);
1263
public static
BFloat16
LogP1(
BFloat16
x) => (
BFloat16
)float.LogP1((float)x);
1266
public static
BFloat16
Log2P1(
BFloat16
x) => (
BFloat16
)float.Log2P1((float)x);
1269
public static
BFloat16
Log10P1(
BFloat16
x) => (
BFloat16
)float.Log10P1((float)x);
1276
public static
BFloat16
operator %(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left % (float)right);
1283
public static
BFloat16
MultiplicativeIdentity => new BFloat16(PositiveOneBits);
1290
public static
BFloat16
operator *(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left * (float)right);
1297
public static
BFloat16
Clamp(
BFloat16
value,
BFloat16
min,
BFloat16
max) => (
BFloat16
)Math.Clamp((float)value, (float)min, (float)max);
1300
public static
BFloat16
CopySign(
BFloat16
value,
BFloat16
sign)
1313
public static
BFloat16
Max(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.Max((float)x, (float)y);
1316
public static
BFloat16
MaxNumber(
BFloat16
x,
BFloat16
y)
1338
public static
BFloat16
Min(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.Min((float)x, (float)y);
1341
public static
BFloat16
MinNumber(
BFloat16
x,
BFloat16
y)
1363
public static int Sign(
BFloat16
value)
1387
public static
BFloat16
One => new BFloat16(PositiveOneBits);
1390
static int INumberBase<
BFloat16
>.Radix => 2;
1393
public static
BFloat16
Zero => new BFloat16(PositiveZeroBits);
1396
public static
BFloat16
Abs(
BFloat16
value) => new BFloat16((ushort)(value._value & ~SignMask));
1400
public static
BFloat16
CreateChecked<TOther>(TOther value)
1403
BFloat16
result;
1405
if (typeof(TOther) == typeof(
BFloat16
))
1407
result = (
BFloat16
)(object)value;
1419
public static
BFloat16
CreateSaturating<TOther>(TOther value)
1422
BFloat16
result;
1424
if (typeof(TOther) == typeof(
BFloat16
))
1426
result = (
BFloat16
)(object)value;
1438
public static
BFloat16
CreateTruncating<TOther>(TOther value)
1441
BFloat16
result;
1443
if (typeof(TOther) == typeof(
BFloat16
))
1445
result = (
BFloat16
)(object)value;
1456
static bool INumberBase<
BFloat16
>.IsCanonical(
BFloat16
value) => true;
1459
static bool INumberBase<
BFloat16
>.IsComplexNumber(
BFloat16
value) => false;
1462
public static bool IsEvenInteger(
BFloat16
value) => float.IsEvenInteger((float)value);
1465
static bool INumberBase<
BFloat16
>.IsImaginaryNumber(
BFloat16
value) => false;
1468
public static bool IsInteger(
BFloat16
value) => float.IsInteger((float)value);
1471
public static bool IsOddInteger(
BFloat16
value) => float.IsOddInteger((float)value);
1474
public static bool IsPositive(
BFloat16
value) => (short)(value._value) >= 0;
1477
public static bool IsRealNumber(
BFloat16
value)
1488
static bool INumberBase<
BFloat16
>.IsZero(
BFloat16
value) => IsZero(value);
1491
public static
BFloat16
MaxMagnitude(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.MaxMagnitude((float)x, (float)y);
1494
public static
BFloat16
MaxMagnitudeNumber(
BFloat16
x,
BFloat16
y)
1502
BFloat16
ax = Abs(x);
1503
BFloat16
ay = Abs(y);
1519
public static
BFloat16
MinMagnitude(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.MinMagnitude((float)x, (float)y);
1522
public static
BFloat16
MinMagnitudeNumber(
BFloat16
x,
BFloat16
y)
1530
BFloat16
ax = Abs(x);
1531
BFloat16
ay = Abs(y);
1548
static bool INumberBase<
BFloat16
>.TryConvertFromChecked<TOther>(TOther value, out
BFloat16
result)
1555
static bool INumberBase<
BFloat16
>.TryConvertFromSaturating<TOther>(TOther value, out
BFloat16
result)
1562
static bool INumberBase<
BFloat16
>.TryConvertFromTruncating<TOther>(TOther value, out
BFloat16
result)
1568
private static bool TryConvertFrom<TOther>(TOther value, out
BFloat16
result)
1577
result = (
BFloat16
)actualValue;
1583
result = (
BFloat16
)actualValue;
1589
result = (
BFloat16
)actualValue;
1601
result = (
BFloat16
)actualValue;
1607
result = (
BFloat16
)actualValue;
1613
result = (
BFloat16
)actualValue;
1619
result = (
BFloat16
)actualValue;
1625
result = (
BFloat16
)actualValue;
1631
result = (
BFloat16
)actualValue;
1637
result = (
BFloat16
)actualValue;
1643
result = (
BFloat16
)actualValue;
1649
result = (
BFloat16
)actualValue;
1655
result = (
BFloat16
)actualValue;
1661
result = (
BFloat16
)actualValue;
1667
result = (
BFloat16
)actualValue;
1673
result = (
BFloat16
)actualValue;
1685
static bool INumberBase<
BFloat16
>.TryConvertToChecked<TOther>(
BFloat16
value, [MaybeNullWhen(false)] out TOther result)
1801
static bool INumberBase<
BFloat16
>.TryConvertToSaturating<TOther>(
BFloat16
value, [MaybeNullWhen(false)] out TOther result)
1808
static bool INumberBase<
BFloat16
>.TryConvertToTruncating<TOther>(
BFloat16
value, [MaybeNullWhen(false)] out TOther result)
1814
private static bool TryConvertTo<TOther>(
BFloat16
value, [MaybeNullWhen(false)] out TOther result)
1949
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider, out result);
1956
public static
BFloat16
Pow(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.Pow((float)x, (float)y);
1963
public static
BFloat16
Cbrt(
BFloat16
x) => (
BFloat16
)float.Cbrt((float)x);
1966
public static
BFloat16
Hypot(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.Hypot((float)x, (float)y);
1969
public static
BFloat16
RootN(
BFloat16
x, int n) => (
BFloat16
)float.RootN((float)x, n);
1972
public static
BFloat16
Sqrt(
BFloat16
x) => (
BFloat16
)float.Sqrt((float)x);
1979
public static
BFloat16
NegativeOne => new BFloat16(NegativeOneBits);
1986
public static
BFloat16
Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, DefaultParseStyle, provider);
1989
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider, out result);
1996
public static
BFloat16
operator -(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left - (float)right);
2003
public static
BFloat16
Acos(
BFloat16
x) => (
BFloat16
)float.Acos((float)x);
2006
public static
BFloat16
AcosPi(
BFloat16
x) => (
BFloat16
)float.AcosPi((float)x);
2009
public static
BFloat16
Asin(
BFloat16
x) => (
BFloat16
)float.Asin((float)x);
2012
public static
BFloat16
AsinPi(
BFloat16
x) => (
BFloat16
)float.AsinPi((float)x);
2015
public static
BFloat16
Atan(
BFloat16
x) => (
BFloat16
)float.Atan((float)x);
2018
public static
BFloat16
AtanPi(
BFloat16
x) => (
BFloat16
)float.AtanPi((float)x);
2021
public static
BFloat16
Cos(
BFloat16
x) => (
BFloat16
)float.Cos((float)x);
2024
public static
BFloat16
CosPi(
BFloat16
x) => (
BFloat16
)float.CosPi((float)x);
2027
public static
BFloat16
DegreesToRadians(
BFloat16
degrees)
2032
return (
BFloat16
)float.DegreesToRadians((float)degrees);
2036
public static
BFloat16
RadiansToDegrees(
BFloat16
radians)
2041
return (
BFloat16
)float.RadiansToDegrees((float)radians);
2045
public static
BFloat16
Sin(
BFloat16
x) => (
BFloat16
)float.Sin((float)x);
2048
public static (
BFloat16
Sin,
BFloat16
Cos) SinCos(
BFloat16
x)
2051
return ((
BFloat16
)sin, (
BFloat16
)cos);
2055
public static (
BFloat16
SinPi,
BFloat16
CosPi) SinCosPi(
BFloat16
x)
2058
return ((
BFloat16
)sinPi, (
BFloat16
)cosPi);
2062
public static
BFloat16
SinPi(
BFloat16
x) => (
BFloat16
)float.SinPi((float)x);
2065
public static
BFloat16
Tan(
BFloat16
x) => (
BFloat16
)float.Tan((float)x);
2068
public static
BFloat16
TanPi(
BFloat16
x) => (
BFloat16
)float.TanPi((float)x);
2075
public static
BFloat16
operator -(
BFloat16
value) => (
BFloat16
)(-(float)value);
2082
public static
BFloat16
operator +(
BFloat16
value) => value;
2089
public static
BFloat16
Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null)
2092
return Number.ParseFloat<byte,
BFloat16
>(utf8Text, style, NumberFormatInfo.GetInstance(provider));
2096
public static bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out
BFloat16
result)
2103
public static
BFloat16
Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, DefaultParseStyle, provider);
2106
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out
BFloat16
result) => TryParse(utf8Text, DefaultParseStyle, provider, out result);
2112
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.NumberBufferLength => 96 + 1 + 1; // 96 for the longest input + 1 for rounding (+1 for the null terminator)
2114
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.ZeroBits => 0;
2115
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.InfinityBits => PositiveInfinityBits;
2117
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.NormalMantissaMask => (1UL << SignificandLength) - 1;
2118
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.DenormalMantissaMask => TrailingSignificandMask;
2120
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinBinaryExponent => 1 - MaxExponent;
2121
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxBinaryExponent => MaxExponent;
2123
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinDecimalExponent => -41;
2124
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxDecimalExponent => 39;
2126
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.ExponentBias => ExponentBias;
2127
static ushort IBinaryFloatParseAndFormatInfo<
BFloat16
>.ExponentBits => BiasedExponentLength;
2129
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.OverflowDecimalExponent => (MaxExponent + (2 * SignificandLength)) / 3;
2130
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.InfinityExponent => MaxBiasedExponent;
2132
static ushort IBinaryFloatParseAndFormatInfo<
BFloat16
>.NormalMantissaBits => SignificandLength;
2133
static ushort IBinaryFloatParseAndFormatInfo<
BFloat16
>.DenormalMantissaBits => TrailingSignificandLength;
2135
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinFastFloatDecimalExponent => -59;
2136
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxFastFloatDecimalExponent => 38;
2138
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinExponentRoundToEven => -24;
2139
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxExponentRoundToEven => 3;
2141
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxExponentFastPath => 3;
2142
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxMantissaFastPath => 2UL << TrailingSignificandLength;
2144
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxRoundTripDigits => 4;
2146
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxPrecisionCustomFormat => 4;
2148
static
BFloat16
IBinaryFloatParseAndFormatInfo<
BFloat16
>.BitsToFloat(ulong bits) => new BFloat16((ushort)(bits));
2150
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.FloatToBits(
BFloat16
value) => value._value;
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
371
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.
BFloat16
))]
System.Runtime.Numerics (41)
System\Numerics\BigInteger.cs (26)
1920
/// <summary>Explicitly converts a big integer to a <see cref="
BFloat16
" /> value.</summary>
1922
/// <returns><paramref name="value" /> converted to <see cref="
BFloat16
" /> value.</returns>
1923
public static explicit operator
BFloat16
(BigInteger value)
1925
return (
BFloat16
)(double)value;
2181
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to a big integer.</summary>
2184
public static explicit operator BigInteger(
BFloat16
value)
4021
else if (typeof(TOther) == typeof(
BFloat16
))
4023
BFloat16
actualValue = (
BFloat16
)(object)value;
4144
else if (typeof(TOther) == typeof(
BFloat16
))
4146
BFloat16
actualValue = (
BFloat16
)(object)value;
4147
result =
BFloat16
.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4267
else if (typeof(TOther) == typeof(
BFloat16
))
4269
BFloat16
actualValue = (
BFloat16
)(object)value;
4270
result =
BFloat16
.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4386
else if (typeof(TOther) == typeof(
BFloat16
))
4388
BFloat16
actualResult = (
BFloat16
)value;
4534
else if (typeof(TOther) == typeof(
BFloat16
))
4536
BFloat16
actualResult = (
BFloat16
)value;
4745
else if (typeof(TOther) == typeof(
BFloat16
))
4747
BFloat16
actualResult = (
BFloat16
)value;
System\Numerics\Complex.cs (15)
837
/// <summary>Implicitly converts a <see cref="
BFloat16
" /> value to a double-precision complex number.</summary>
840
public static implicit operator Complex(
BFloat16
value)
1551
else if (typeof(TOther) == typeof(
BFloat16
))
1553
BFloat16
actualValue = (
BFloat16
)(object)value;
1690
else if (typeof(TOther) == typeof(
BFloat16
))
1692
BFloat16
actualResult = (value.m_imaginary != 0) ?
BFloat16
.NaN : (
BFloat16
)value.m_real;
1889
else if (typeof(TOther) == typeof(
BFloat16
))
1891
BFloat16
actualResult = (
BFloat16
)value.m_real;
2031
else if (typeof(TOther) == typeof(
BFloat16
))
2033
BFloat16
actualResult = (
BFloat16
)value.m_real;