31 instantiations of BFloat16
System.Private.CoreLib (31)
src\runtime\src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (2)
1018
public static BFloat16 Int16BitsToBFloat16(short value) => new
BFloat16
((ushort)(value));
1090
public static BFloat16 UInt16BitsToBFloat16(ushort value) => new
BFloat16
(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\BFloat16.cs (29)
84
public static BFloat16 Epsilon => new
BFloat16
(EpsilonBits);
86
public static BFloat16 PositiveInfinity => new
BFloat16
(PositiveInfinityBits);
88
public static BFloat16 NegativeInfinity => new
BFloat16
(NegativeInfinityBits);
90
public static BFloat16 NaN => new
BFloat16
(NegativeQNaNBits);
93
public static BFloat16 MinValue => new
BFloat16
(MinValueBits);
96
public static BFloat16 MaxValue => new
BFloat16
(MaxValueBits);
503
return new
BFloat16
((ushort)bitValue);
550
return new
BFloat16
((ushort)(roundedValueBits >> 16));
596
return new
BFloat16
((ushort)(!float.IsNaN(value) ? roundedBits : ((bits >> 16) | QuietBit)));
615
return new
BFloat16
((ushort)(roundedValueBits >> 16));
859
static BFloat16 IAdditiveIdentity<BFloat16, BFloat16>.AdditiveIdentity => new
BFloat16
(PositiveZeroBits);
866
static BFloat16 IBinaryNumber<BFloat16>.AllBitsSet => new
BFloat16
(0xFFFF);
907
return new
BFloat16
((ushort)(left._value & right._value));
913
return new
BFloat16
((ushort)(left._value | right._value));
919
return new
BFloat16
((ushort)(left._value ^ right._value));
925
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));
2000
public static BFloat16 NegativeOne => new
BFloat16
(NegativeOneBits);
2169
static BFloat16 IBinaryFloatParseAndFormatInfo<BFloat16>.BitsToFloat(ulong bits) => new
BFloat16
((ushort)(bits));
678 references to BFloat16
System.Private.CoreLib (646)
src\runtime\src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (26)
312
/// Returns the specified <see cref="
BFloat16
"/> value as an array of bytes.
316
public static unsafe byte[] GetBytes(
BFloat16
value)
318
byte[] bytes = new byte[sizeof(
BFloat16
)];
325
/// Converts a <see cref="
BFloat16
"/> value into a span of bytes.
327
/// <param name="destination">When this method returns, the bytes representing the converted <see cref="
BFloat16
"/> value.</param>
328
/// <param name="value">The <see cref="
BFloat16
"/> value to convert.</param>
330
public static unsafe bool TryWriteBytes(Span<byte> destination,
BFloat16
value)
332
if (destination.Length < sizeof(
BFloat16
))
725
/// Returns a <see cref="
BFloat16
"/> number converted from two bytes at a specified position in a byte array.
729
/// <returns>A <see cref="
BFloat16
"/> number signed integer formed by two bytes beginning at <paramref name="startIndex"/>.</returns>
733
public static
BFloat16
ToBFloat16(byte[] value, int startIndex) => Int16BitsToBFloat16(ToInt16(value, startIndex));
736
/// Converts a read-only byte span into a <see cref="
BFloat16
"/> value.
739
/// <returns>A <see cref="
BFloat16
"/> value representing the converted bytes.</returns>
742
public static unsafe
BFloat16
ToBFloat16(ReadOnlySpan<byte> value)
744
if (value.Length < sizeof(
BFloat16
))
746
return Unsafe.ReadUnaligned<
BFloat16
>(ref MemoryMarshal.GetReference(value));
1005
/// Converts the specified <see cref="
BFloat16
"/> number to a 16-bit signed integer.
1010
public static short BFloat16ToInt16Bits(
BFloat16
value) => (short)value._value;
1013
/// Converts the specified 16-bit signed integer to a <see cref="
BFloat16
"/> number.
1016
/// <returns>A <see cref="
BFloat16
"/> number whose bits are identical to <paramref name="value"/>.</returns>
1018
public static
BFloat16
Int16BitsToBFloat16(short value) => new BFloat16((ushort)(value));
1075
/// Converts the specified <see cref="
BFloat16
"/> number to a 16-bit unsigned integer.
1081
public static ushort BFloat16ToUInt16Bits(
BFloat16
value) => value._value;
1084
/// Converts the specified 16-bit unsigned integer to a <see cref="
BFloat16
"/> number.
1087
/// <returns>A <see cref="
BFloat16
"/> number whose bits are identical to <paramref name="value"/>.</returns>
1090
public static
BFloat16
UInt16BitsToBFloat16(ushort value) => new BFloat16(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReadBigEndian.cs (7)
47
/// Reads a <see cref="
BFloat16
" /> from the beginning of a read-only span of bytes, as big endian.
53
/// <paramref name="source"/> is too small to contain a <see cref="
BFloat16
" />.
56
public static
BFloat16
ReadBFloat16BigEndian(ReadOnlySpan<byte> source)
60
MemoryMarshal.Read<
BFloat16
>(source);
300
/// Reads a <see cref="
BFloat16
" /> from the beginning of a read-only span of bytes, as big endian.
305
/// <see langword="true" /> if the span is large enough to contain a <see cref="
BFloat16
" />; otherwise, <see langword="false" />.
309
public static bool TryReadBFloat16BigEndian(ReadOnlySpan<byte> source, out
BFloat16
value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReadLittleEndian.cs (6)
47
/// Reads a <see cref="
BFloat16
" /> from the beginning of a read-only span of bytes, as little endian.
56
public static
BFloat16
ReadBFloat16LittleEndian(ReadOnlySpan<byte> source)
60
MemoryMarshal.Read<
BFloat16
>(source);
300
/// Reads a <see cref="
BFloat16
" /> from the beginning of a read-only span of bytes, as little endian.
305
/// <see langword="true" /> if the span is large enough to contain a <see cref="
BFloat16
" />; otherwise, <see langword="false" />.
309
public static bool TryReadBFloat16LittleEndian(ReadOnlySpan<byte> source, out
BFloat16
value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.WriteBigEndian.cs (6)
59
/// Writes a <see cref="
BFloat16
" /> into a span of bytes, as big endian.
65
/// <paramref name="destination" /> is too small to contain a <see cref="
BFloat16
" />.
68
public static void WriteBFloat16BigEndian(Span<byte> destination,
BFloat16
value)
382
/// Writes a <see cref="
BFloat16
" /> into a span of bytes, as big endian.
387
/// <see langword="true" /> if the span is large enough to contain a <see cref="
BFloat16
" />; otherwise, <see langword="false" />.
391
public static bool TryWriteBFloat16BigEndian(Span<byte> destination,
BFloat16
value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.WriteLittleEndian.cs (6)
59
/// Writes a <see cref="
BFloat16
" /> into a span of bytes, as little endian.
65
/// <paramref name="destination" /> is too small to contain a <see cref="
BFloat16
" />.
68
public static void WriteBFloat16LittleEndian(Span<byte> destination,
BFloat16
value)
382
/// Writes a <see cref="
BFloat16
" /> into a span of bytes, as little endian.
387
/// <see langword="true" /> if the span is large enough to contain a <see cref="
BFloat16
" />; otherwise, <see langword="false" />.
391
public static bool TryWriteBFloat16LittleEndian(Span<byte> destination,
BFloat16
value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\BFloat16.cs (590)
18
IComparable<
BFloat16
>,
19
IEquatable<
BFloat16
>,
20
IBinaryFloatingPointIeee754<
BFloat16
>,
21
IMinMaxValue<
BFloat16
>,
23
IBinaryFloatParseAndFormatInfo<
BFloat16
>
84
public static
BFloat16
Epsilon => new BFloat16(EpsilonBits);
86
public static
BFloat16
PositiveInfinity => new BFloat16(PositiveInfinityBits);
88
public static
BFloat16
NegativeInfinity => new BFloat16(NegativeInfinityBits);
90
public static
BFloat16
NaN => new BFloat16(NegativeQNaNBits);
93
public static
BFloat16
MinValue => new BFloat16(MinValueBits);
96
public static
BFloat16
MaxValue => new BFloat16(MaxValueBits);
151
public static bool IsFinite(
BFloat16
value)
159
public static bool IsInfinity(
BFloat16
value)
167
public static bool IsNaN(
BFloat16
value)
174
internal static bool IsNaNOrZero(
BFloat16
value)
182
public static bool IsNegative(
BFloat16
value)
189
public static bool IsNegativeInfinity(
BFloat16
value)
197
public static bool IsNormal(
BFloat16
value)
205
public static bool IsPositiveInfinity(
BFloat16
value)
213
public static bool IsSubnormal(
BFloat16
value)
220
public static bool IsZero(
BFloat16
value)
227
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> in the default parse style.
230
/// <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>
231
public static
BFloat16
Parse(string s) => Parse(s, DefaultParseStyle, provider: null);
234
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> in the given <see cref="NumberStyles"/>.
238
/// <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>
239
public static
BFloat16
Parse(string s, NumberStyles style) => Parse(s, style, provider: null);
242
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> and <see cref="IFormatProvider"/>.
246
/// <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>
247
public static
BFloat16
Parse(string s, IFormatProvider? provider) => Parse(s, DefaultParseStyle, provider);
250
/// Parses a <see cref="
BFloat16
"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
255
/// <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>
256
public static
BFloat16
Parse(string s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null)
266
/// Parses a <see cref="
BFloat16
"/> from a <see cref="ReadOnlySpan{Char}"/> and <see cref="IFormatProvider"/>.
271
/// <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>
272
public static
BFloat16
Parse(ReadOnlySpan<char> s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null)
275
return Number.ParseFloat<char,
BFloat16
>(s, style, NumberFormatInfo.GetInstance(provider));
279
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="string"/> in the default parse style.
282
/// <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>
284
public static bool TryParse([NotNullWhen(true)] string? s, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider: null, out result);
287
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="ReadOnlySpan{Char}"/> in the default parse style.
290
/// <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>
292
public static bool TryParse(ReadOnlySpan<char> s, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider: null, out result);
294
/// <summary>Tries to convert a UTF-8 character span containing the string representation of a number to its <see cref="
BFloat16
"/> number equivalent.</summary>
296
/// <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>
298
public static bool TryParse(ReadOnlySpan<byte> utf8Text, out
BFloat16
result) => TryParse(utf8Text, DefaultParseStyle, provider: null, out result);
301
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
306
/// <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>
308
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out
BFloat16
result)
315
/// Tries to parse a <see cref="
BFloat16
"/> from a <see cref="ReadOnlySpan{Char}"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>.
320
/// <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>
322
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out
BFloat16
result)
334
/// <exception cref="ArgumentException">Thrown when <paramref name="obj"/> is not of type <see cref="
BFloat16
"/>.</exception>
337
if (obj is not
BFloat16
other)
348
public int CompareTo(
BFloat16
other) => ((float)this).CompareTo((float)other);
351
public static bool operator ==(
BFloat16
left,
BFloat16
right) => (float)left == (float)right;
354
public static bool operator !=(
BFloat16
left,
BFloat16
right) => (float)left != (float)right;
357
public static bool operator <(
BFloat16
left,
BFloat16
right) => (float)left < (float)right;
360
public static bool operator >(
BFloat16
left,
BFloat16
right) => (float)left > (float)right;
363
public static bool operator <=(
BFloat16
left,
BFloat16
right) => (float)left <= (float)right;
366
public static bool operator >=(
BFloat16
left,
BFloat16
right) => (float)left >= (float)right;
373
public bool Equals(
BFloat16
other) => ((float)this).Equals((float)other);
378
public override bool Equals(object? obj) => obj is
BFloat16
other && Equals(other);
437
/// <summary>Explicitly converts a <see cref="char" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
439
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
440
public static explicit operator
BFloat16
(char value) => (
BFloat16
)(float)value;
442
/// <summary>Explicitly converts a <see cref="decimal" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
444
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
447
public static explicit operator
BFloat16
(decimal value) => (
BFloat16
)(double)value;
449
/// <summary>Explicitly converts a <see cref="double" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
451
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
452
public static explicit operator
BFloat16
(double value)
531
private static unsafe
BFloat16
RoundFromSigned<TInteger>(TInteger value)
553
/// <summary>Explicitly converts a <see cref="short" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
555
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
556
public static explicit operator
BFloat16
(short value) => (
BFloat16
)(float)value;
558
/// <summary>Explicitly converts a <see cref="Half" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
560
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
561
public static explicit operator
BFloat16
(Half value) => (
BFloat16
)(float)value;
563
/// <summary>Explicitly converts a <see cref="int" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
565
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
566
public static explicit operator
BFloat16
(int value) => RoundFromSigned(value);
568
/// <summary>Explicitly converts a <see cref="long" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
570
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
571
public static explicit operator
BFloat16
(long value) => RoundFromSigned(value);
573
/// <summary>Explicitly converts a <see cref="Int128" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
575
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
576
public static explicit operator
BFloat16
(Int128 value) => RoundFromSigned(value);
578
/// <summary>Explicitly converts a <see cref="nint" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
580
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
581
public static explicit operator
BFloat16
(nint value) => RoundFromSigned(value);
583
/// <summary>Explicitly converts a <see cref="float" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
585
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
586
public static explicit operator
BFloat16
(float value)
599
private static unsafe
BFloat16
RoundFromUnsigned<TInteger>(TInteger value)
618
/// <summary>Explicitly converts a <see cref="ushort" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
620
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
622
public static explicit operator
BFloat16
(ushort value) => (
BFloat16
)(float)value;
624
/// <summary>Explicitly converts a <see cref="uint" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
626
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
628
public static explicit operator
BFloat16
(uint value) => RoundFromUnsigned(value);
630
/// <summary>Explicitly converts a <see cref="ulong" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
632
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
634
public static explicit operator
BFloat16
(ulong value) => RoundFromUnsigned(value);
636
/// <summary>Explicitly converts a <see cref="nuint" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
638
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
640
public static explicit operator
BFloat16
(nuint value) => RoundFromUnsigned(value);
642
/// <summary>Explicitly converts a <see cref="UInt128" /> value to its nearest representable <see cref="
BFloat16
"/> value.</summary>
644
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
"/> value.</returns>
646
public static explicit operator
BFloat16
(UInt128 value) => RoundFromUnsigned(value);
652
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="byte" /> value.</summary>
655
public static explicit operator byte(
BFloat16
value) => (byte)(float)value;
657
/// <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>
661
public static explicit operator checked byte(
BFloat16
value) => checked((byte)(float)value);
663
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="char" /> value.</summary>
666
public static explicit operator char(
BFloat16
value) => (char)(float)value;
668
/// <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>
672
public static explicit operator checked char(
BFloat16
value) => checked((char)(float)value);
674
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="decimal" /> value.</summary>
677
public static explicit operator decimal(
BFloat16
value) => (decimal)(float)value;
679
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="short" /> value.</summary>
682
public static explicit operator short(
BFloat16
value) => (short)(float)value;
684
/// <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>
688
public static explicit operator checked short(
BFloat16
value) => checked((short)(float)value);
690
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="int" /> value.</summary>
693
public static explicit operator int(
BFloat16
value) => (int)(float)value;
695
/// <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>
699
public static explicit operator checked int(
BFloat16
value) => checked((int)(float)value);
701
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="long" /> value.</summary>
704
public static explicit operator long(
BFloat16
value) => (long)(float)value;
706
/// <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>
710
public static explicit operator checked long(
BFloat16
value) => checked((long)(float)value);
712
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="Int128"/>.</summary>
715
public static explicit operator Int128(
BFloat16
value) => (Int128)(double)(value);
717
/// <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>
721
public static explicit operator checked Int128(
BFloat16
value) => checked((Int128)(double)(value));
723
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="IntPtr" /> value.</summary>
726
public static explicit operator nint(
BFloat16
value) => (nint)(float)value;
728
/// <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>
732
public static explicit operator checked nint(
BFloat16
value) => checked((nint)(float)value);
734
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="sbyte" /> value.</summary>
738
public static explicit operator sbyte(
BFloat16
value) => (sbyte)(float)value;
740
/// <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>
745
public static explicit operator checked sbyte(
BFloat16
value) => checked((sbyte)(float)value);
747
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="ushort" /> value.</summary>
751
public static explicit operator ushort(
BFloat16
value) => (ushort)(float)value;
753
/// <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>
758
public static explicit operator checked ushort(
BFloat16
value) => checked((ushort)(float)value);
760
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="uint" /> value.</summary>
764
public static explicit operator uint(
BFloat16
value) => (uint)(float)value;
766
/// <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>
771
public static explicit operator checked uint(
BFloat16
value) => checked((uint)(float)value);
773
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="ulong" /> value.</summary>
777
public static explicit operator ulong(
BFloat16
value) => (ulong)(float)value;
779
/// <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>
784
public static explicit operator checked ulong(
BFloat16
value) => checked((ulong)(float)value);
786
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="UInt128"/>.</summary>
790
public static explicit operator UInt128(
BFloat16
value) => (UInt128)(double)(value);
792
/// <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>
797
public static explicit operator checked UInt128(
BFloat16
value) => checked((UInt128)(double)(value));
799
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="UIntPtr" /> value.</summary>
803
public static explicit operator nuint(
BFloat16
value) => (nuint)(float)value;
805
/// <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>
810
public static explicit operator checked nuint(
BFloat16
value) => checked((nuint)(float)value);
812
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="Half" /> value.</summary>
815
public static explicit operator Half(
BFloat16
value) => (Half)(float)value;
821
/// <summary>Implicitly converts a <see cref="byte" /> value to its nearest representable <see cref="
BFloat16
" /> value.</summary>
823
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
" /> value.</returns>
824
public static implicit operator
BFloat16
(byte value) => (
BFloat16
)(float)value;
826
/// <summary>Implicitly converts a <see cref="sbyte" /> value to its nearest representable <see cref="
BFloat16
" /> value.</summary>
828
/// <returns><paramref name="value" /> converted to its nearest representable <see cref="
BFloat16
" /> value.</returns>
830
public static implicit operator
BFloat16
(sbyte value) => (
BFloat16
)(float)value;
836
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="float"/> value.</summary>
840
public static explicit operator float(
BFloat16
value) => BitConverter.Int32BitsToSingle(value._value << 16);
842
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to its nearest representable <see cref="double"/> value.</summary>
845
public static explicit operator double(
BFloat16
value) => (double)(float)value;
852
public static
BFloat16
operator +(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left + (float)right);
859
static
BFloat16
IAdditiveIdentity<
BFloat16
,
BFloat16
>.AdditiveIdentity => new BFloat16(PositiveZeroBits);
866
static
BFloat16
IBinaryNumber<
BFloat16
>.AllBitsSet => new BFloat16(0xFFFF);
869
public static bool IsPow2(
BFloat16
value)
898
public static
BFloat16
Log2(
BFloat16
value) => (
BFloat16
)float.Log2((float)value);
905
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator &(
BFloat16
left,
BFloat16
right)
911
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator |(
BFloat16
left,
BFloat16
right)
917
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator ^(
BFloat16
left,
BFloat16
right)
923
static
BFloat16
IBitwiseOperators<
BFloat16
,
BFloat16
,
BFloat16
>.operator ~(
BFloat16
value)
933
public static
BFloat16
operator --(
BFloat16
value)
937
return (
BFloat16
)tmp;
945
public static
BFloat16
operator /(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left / (float)right);
952
public static
BFloat16
Exp(
BFloat16
x) => (
BFloat16
)float.Exp((float)x);
955
public static
BFloat16
ExpM1(
BFloat16
x) => (
BFloat16
)float.ExpM1((float)x);
958
public static
BFloat16
Exp2(
BFloat16
x) => (
BFloat16
)float.Exp2((float)x);
961
public static
BFloat16
Exp2M1(
BFloat16
x) => (
BFloat16
)float.Exp2M1((float)x);
964
public static
BFloat16
Exp10(
BFloat16
x) => (
BFloat16
)float.Exp10((float)x);
967
public static
BFloat16
Exp10M1(
BFloat16
x) => (
BFloat16
)float.Exp10M1((float)x);
974
public static
BFloat16
Ceiling(
BFloat16
x) => (
BFloat16
)float.Ceiling((float)x);
977
public static
BFloat16
Floor(
BFloat16
x) => (
BFloat16
)float.Floor((float)x);
980
public static
BFloat16
Round(
BFloat16
x) => (
BFloat16
)float.Round((float)x);
983
public static
BFloat16
Round(
BFloat16
x, int digits) => (
BFloat16
)float.Round((float)x, digits);
986
public static
BFloat16
Round(
BFloat16
x, MidpointRounding mode) => (
BFloat16
)float.Round((float)x, mode);
989
public static
BFloat16
Round(
BFloat16
x, int digits, MidpointRounding mode) => (
BFloat16
)float.Round((float)x, digits, mode);
992
public static
BFloat16
Truncate(
BFloat16
x) => (
BFloat16
)float.Truncate((float)x);
995
int IFloatingPoint<
BFloat16
>.GetExponentByteCount() => sizeof(sbyte);
998
int IFloatingPoint<
BFloat16
>.GetExponentShortestBitLength()
1013
int IFloatingPoint<
BFloat16
>.GetSignificandByteCount() => sizeof(byte);
1016
int IFloatingPoint<
BFloat16
>.GetSignificandBitLength() => SignificandLength;
1019
bool IFloatingPoint<
BFloat16
>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten)
1033
bool IFloatingPoint<
BFloat16
>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten)
1047
bool IFloatingPoint<
BFloat16
>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten)
1061
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)
1945
public static bool TryParsePartial([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out
BFloat16
result, out int charsConsumed)
1952
public static bool TryParsePartial(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out
BFloat16
result, out int charsConsumed)
1959
public static bool TryParsePartial(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out
BFloat16
result, out int bytesConsumed)
1970
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider, out result);
1977
public static
BFloat16
Pow(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.Pow((float)x, (float)y);
1984
public static
BFloat16
Cbrt(
BFloat16
x) => (
BFloat16
)float.Cbrt((float)x);
1987
public static
BFloat16
Hypot(
BFloat16
x,
BFloat16
y) => (
BFloat16
)float.Hypot((float)x, (float)y);
1990
public static
BFloat16
RootN(
BFloat16
x, int n) => (
BFloat16
)float.RootN((float)x, n);
1993
public static
BFloat16
Sqrt(
BFloat16
x) => (
BFloat16
)float.Sqrt((float)x);
2000
public static
BFloat16
NegativeOne => new BFloat16(NegativeOneBits);
2007
public static
BFloat16
Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, DefaultParseStyle, provider);
2010
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out
BFloat16
result) => TryParse(s, DefaultParseStyle, provider, out result);
2017
public static
BFloat16
operator -(
BFloat16
left,
BFloat16
right) => (
BFloat16
)((float)left - (float)right);
2024
public static
BFloat16
Acos(
BFloat16
x) => (
BFloat16
)float.Acos((float)x);
2027
public static
BFloat16
AcosPi(
BFloat16
x) => (
BFloat16
)float.AcosPi((float)x);
2030
public static
BFloat16
Asin(
BFloat16
x) => (
BFloat16
)float.Asin((float)x);
2033
public static
BFloat16
AsinPi(
BFloat16
x) => (
BFloat16
)float.AsinPi((float)x);
2036
public static
BFloat16
Atan(
BFloat16
x) => (
BFloat16
)float.Atan((float)x);
2039
public static
BFloat16
AtanPi(
BFloat16
x) => (
BFloat16
)float.AtanPi((float)x);
2042
public static
BFloat16
Cos(
BFloat16
x) => (
BFloat16
)float.Cos((float)x);
2045
public static
BFloat16
CosPi(
BFloat16
x) => (
BFloat16
)float.CosPi((float)x);
2048
public static
BFloat16
DegreesToRadians(
BFloat16
degrees)
2053
return (
BFloat16
)float.DegreesToRadians((float)degrees);
2057
public static
BFloat16
RadiansToDegrees(
BFloat16
radians)
2062
return (
BFloat16
)float.RadiansToDegrees((float)radians);
2066
public static
BFloat16
Sin(
BFloat16
x) => (
BFloat16
)float.Sin((float)x);
2069
public static (
BFloat16
Sin,
BFloat16
Cos) SinCos(
BFloat16
x)
2072
return ((
BFloat16
)sin, (
BFloat16
)cos);
2076
public static (
BFloat16
SinPi,
BFloat16
CosPi) SinCosPi(
BFloat16
x)
2079
return ((
BFloat16
)sinPi, (
BFloat16
)cosPi);
2083
public static
BFloat16
SinPi(
BFloat16
x) => (
BFloat16
)float.SinPi((float)x);
2086
public static
BFloat16
Tan(
BFloat16
x) => (
BFloat16
)float.Tan((float)x);
2089
public static
BFloat16
TanPi(
BFloat16
x) => (
BFloat16
)float.TanPi((float)x);
2096
public static
BFloat16
operator -(
BFloat16
value) => (
BFloat16
)(-(float)value);
2103
public static
BFloat16
operator +(
BFloat16
value) => value;
2110
public static
BFloat16
Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null)
2113
return Number.ParseFloat<byte,
BFloat16
>(utf8Text, style, NumberFormatInfo.GetInstance(provider));
2117
public static bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out
BFloat16
result)
2124
public static
BFloat16
Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, DefaultParseStyle, provider);
2127
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out
BFloat16
result) => TryParse(utf8Text, DefaultParseStyle, provider, out result);
2133
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.NumberBufferLength => 96 + 1 + 1; // 96 for the longest input + 1 for rounding (+1 for the null terminator)
2135
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.ZeroBits => 0;
2136
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.InfinityBits => PositiveInfinityBits;
2138
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.NormalMantissaMask => (1UL << SignificandLength) - 1;
2139
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.DenormalMantissaMask => TrailingSignificandMask;
2141
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinBinaryExponent => 1 - MaxExponent;
2142
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxBinaryExponent => MaxExponent;
2144
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinDecimalExponent => -41;
2145
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxDecimalExponent => 39;
2147
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.ExponentBias => ExponentBias;
2148
static ushort IBinaryFloatParseAndFormatInfo<
BFloat16
>.ExponentBits => BiasedExponentLength;
2150
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.OverflowDecimalExponent => (MaxExponent + (2 * SignificandLength)) / 3;
2151
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.InfinityExponent => MaxBiasedExponent;
2153
static ushort IBinaryFloatParseAndFormatInfo<
BFloat16
>.NormalMantissaBits => SignificandLength;
2154
static ushort IBinaryFloatParseAndFormatInfo<
BFloat16
>.DenormalMantissaBits => TrailingSignificandLength;
2156
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinFastFloatDecimalExponent => -59;
2157
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxFastFloatDecimalExponent => 38;
2159
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MinExponentRoundToEven => -24;
2160
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxExponentRoundToEven => 3;
2162
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxExponentFastPath => 3;
2163
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxMantissaFastPath => 2UL << TrailingSignificandLength;
2165
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxRoundTripDigits => 4;
2167
static int IBinaryFloatParseAndFormatInfo<
BFloat16
>.MaxPrecisionCustomFormat => 4;
2169
static
BFloat16
IBinaryFloatParseAndFormatInfo<
BFloat16
>.BitsToFloat(ulong bits) => new BFloat16((ushort)(bits));
2171
static ulong IBinaryFloatParseAndFormatInfo<
BFloat16
>.FloatToBits(
BFloat16
value) => value._value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\TotalOrderIeee754Comparer.cs (5)
66
else if (typeof(T) == typeof(
BFloat16
))
68
return CompareIntegerSemantic(Unsafe.BitCast<
BFloat16
, short>((
BFloat16
)(object)x!), Unsafe.BitCast<
BFloat16
, short>((
BFloat16
)(object)y!));
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
376
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.
BFloat16
))]
System.Runtime.Numerics (31)
System\Numerics\BigInteger.cs (29)
2217
/// <summary>Explicitly converts a big integer to a <see cref="
BFloat16
" /> value.</summary>
2219
/// <returns><paramref name="value" /> converted to <see cref="
BFloat16
" /> value.</returns>
2220
public static explicit operator
BFloat16
(BigInteger value)
2227
return (
BFloat16
)sign;
2235
BFloat16
result = (
BFloat16
)ToUInt64(bits);
2239
return (
BFloat16
)ConvertToDouble(value, precision: 8);
2494
/// <summary>Explicitly converts a <see cref="
BFloat16
" /> value to a big integer.</summary>
2497
public static explicit operator BigInteger(
BFloat16
value) => new BigInteger((float)value);
4305
else if (typeof(TOther) == typeof(
BFloat16
))
4307
BFloat16
actualValue = (
BFloat16
)(object)value;
4428
else if (typeof(TOther) == typeof(
BFloat16
))
4430
BFloat16
actualValue = (
BFloat16
)(object)value;
4431
result =
BFloat16
.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4551
else if (typeof(TOther) == typeof(
BFloat16
))
4553
BFloat16
actualValue = (
BFloat16
)(object)value;
4554
result =
BFloat16
.IsNaN(actualValue) ? Zero : (BigInteger)actualValue;
4670
else if (typeof(TOther) == typeof(
BFloat16
))
4672
BFloat16
actualResult = (
BFloat16
)value;
4818
else if (typeof(TOther) == typeof(
BFloat16
))
4820
BFloat16
actualResult = (
BFloat16
)value;
5029
else if (typeof(TOther) == typeof(
BFloat16
))
5031
BFloat16
actualResult = (
BFloat16
)value;
System\Numerics\Complex.cs (2)
412
/// <summary>Implicitly converts a <see cref="
BFloat16
" /> value to a double-precision complex number.</summary>
415
public static implicit operator Complex(
BFloat16
value)