29 instantiations of Half
System.Private.CoreLib (29)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (2)
948public static Half Int16BitsToHalf(short value) => new Half((ushort)(value)); 1002public static Half UInt16BitsToHalf(ushort value) => new Half(value);
src\libraries\System.Private.CoreLib\src\System\Half.cs (27)
89public static Half Epsilon => new Half(EpsilonBits); // 5.9604645E-08 91public static Half PositiveInfinity => new Half(PositiveInfinityBits); // 1.0 / 0.0; 93public static Half NegativeInfinity => new Half(NegativeInfinityBits); // -1.0 / 0.0 95public static Half NaN => new Half(NegativeQNaNBits); // 0.0 / 0.0 98public static Half MinValue => new Half(MinValueBits); // -65504 101public static Half MaxValue => new Half(MaxValueBits); // 65504 592return new Half(sign, 0, 0); 594return new Half(RoundPackToHalf(sign, (short)(exp - 0x3F1), (ushort)(sigHalf | 0x4000))); 1100return IsNaN(value) ? value : new Half((ushort)(value._value ^ SignMask)); 1150return new Half(sign, (ushort)exp, sig)._value; 1198static Half IAdditiveIdentity<Half, Half>.AdditiveIdentity => new Half(PositiveZeroBits); 1246return new Half((ushort)(left._value & right._value)); 1252return new Half((ushort)(left._value | right._value)); 1258return new Half((ushort)(left._value ^ right._value)); 1264return new Half((ushort)(~value._value)); 1424public static Half E => new Half(EBits); 1427public static Half Pi => new Half(PiBits); 1430public static Half Tau => new Half(TauBits); 1437public static Half NegativeZero => new Half(NegativeZeroBits); 1475return new Half((ushort)bits); 1508return new Half((ushort)bits); 1628public static Half MultiplicativeIdentity => new Half(PositiveOneBits); 1664return new Half((ushort)((xbits & ~SignMask) | (ybits & SignMask))); 1748public static Half One => new Half(PositiveOneBits); 1754public static Half Zero => new Half(PositiveZeroBits); 1757public static Half Abs(Half value) => new Half((ushort)(value._value & ~SignMask)); 2194public static Half NegativeOne => new Half(NegativeOneBits);
938 references to Half
Microsoft.AspNetCore.Components.Endpoints (6)
FormMapping\WellKnownConverters.cs (6)
36{ typeof(Half), new ParsableConverter<Half>() }, 68converters.Add(typeof(Half?), new NullableConverter<Half>((FormDataConverter<Half>)converters[typeof(Half)]));
Microsoft.AspNetCore.Components.Endpoints.Tests (6)
Binding\FormDataMapperTests.cs (6)
2119{ "12.56", typeof(Half?), new Half?((Half)12.56f)}, 2161{ typeof(Half?) }, 2204{ "12.56", typeof(Half), (Half)12.56f },
Microsoft.AspNetCore.Http.Extensions (10)
src\Components\Endpoints\src\FormMapping\WellKnownConverters.cs (6)
36{ typeof(Half), new ParsableConverter<Half>() }, 68converters.Add(typeof(Half?), new NullableConverter<Half>((FormDataConverter<Half>)converters[typeof(Half)]));
src\Shared\ParameterBindingMethodCache.cs (4)
647else if (type == typeof(Half)) 649method = typeof(Half).GetMethod( 650nameof(Half.TryParse), 652new[] { typeof(string), typeof(NumberStyles), typeof(IFormatProvider), typeof(Half).MakeByRefType() });
Microsoft.AspNetCore.Http.Extensions.Tests (7)
ParameterBindingMethodCacheTests.cs (1)
19[InlineData(typeof(Half))]
RequestDelegateFactoryTests.cs (4)
323new object[] { (Action<HttpContext, Half[]>)Store, new[] { "0.5" }, new[] { (Half)0.5f } }, 374new object[] { (Action<HttpContext, Half>)Store, "0.5", (Half)0.5f },
RequestDelegateGenerator\RequestDelegateCreationTests.Arrays.cs (1)
130new object[] { "Half[]", new[] { "0.5" }, new[] { (Half)0.5f } },
RequestDelegateGenerator\RequestDelegateCreationTests.TryParse.cs (1)
37new object[] { "Half", "0.5", (Half)0.5f },
Microsoft.AspNetCore.Mvc.Abstractions (4)
src\Shared\ParameterBindingMethodCache.cs (4)
647else if (type == typeof(Half)) 649method = typeof(Half).GetMethod( 650nameof(Half.TryParse), 652new[] { typeof(string), typeof(NumberStyles), typeof(IFormatProvider), typeof(Half).MakeByRefType() });
Microsoft.AspNetCore.OpenApi (5)
Services\OpenApiConstants.cs (1)
51typeof(Half),
src\Shared\ParameterBindingMethodCache.cs (4)
647else if (type == typeof(Half)) 649method = typeof(Half).GetMethod( 650nameof(Half.TryParse), 652new[] { typeof(string), typeof(NumberStyles), typeof(IFormatProvider), typeof(Half).MakeByRefType() });
Microsoft.CodeAnalysis (17)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (17)
311|| typeof(T) == typeof(Half) 626if (typeof(T) == typeof(Half)) 627return (Half)(object)left < (Half)(object)right; 660if (typeof(T) == typeof(Half)) 661return (Half)(object)left > (Half)(object)right; 913|| typeof(TKey) == typeof(Half) 1177if (typeof(TKey) == typeof(Half)) 1178return (Half)(object)left < (Half)(object)right; 1211if (typeof(TKey) == typeof(Half)) 1212return (Half)(object)left > (Half)(object)right; 1244|| (typeof(TKey) == typeof(Half) && Half.IsNaN((Half)(object)keys[i]))
Microsoft.CodeAnalysis.Workspaces (17)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (17)
311|| typeof(T) == typeof(Half) 626if (typeof(T) == typeof(Half)) 627return (Half)(object)left < (Half)(object)right; 660if (typeof(T) == typeof(Half)) 661return (Half)(object)left > (Half)(object)right; 913|| typeof(TKey) == typeof(Half) 1177if (typeof(TKey) == typeof(Half)) 1178return (Half)(object)left < (Half)(object)right; 1211if (typeof(TKey) == typeof(Half)) 1212return (Half)(object)left > (Half)(object)right; 1244|| (typeof(TKey) == typeof(Half) && Half.IsNaN((Half)(object)keys[i]))
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (17)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (17)
311|| typeof(T) == typeof(Half) 626if (typeof(T) == typeof(Half)) 627return (Half)(object)left < (Half)(object)right; 660if (typeof(T) == typeof(Half)) 661return (Half)(object)left > (Half)(object)right; 913|| typeof(TKey) == typeof(Half) 1177if (typeof(TKey) == typeof(Half)) 1178return (Half)(object)left < (Half)(object)right; 1211if (typeof(TKey) == typeof(Half)) 1212return (Half)(object)left > (Half)(object)right; 1244|| (typeof(TKey) == typeof(Half) && Half.IsNaN((Half)(object)keys[i]))
Microsoft.Extensions.AI.Abstractions (2)
Embeddings\Embedding.cs (1)
17[JsonDerivedType(typeof(Embedding<Half>), typeDiscriminator: "float16")]
Utilities\AIJsonUtilities.Defaults.cs (1)
111[JsonSerializable(typeof(Embedding<Half>))]
Microsoft.Extensions.AI.Abstractions.Tests (10)
Embeddings\EmbeddingTests.cs (7)
68Half[] halfs = [(Half)1f, (Half)2f, (Half)3f]; 69Embedding<Half> e = new(halfs); 74Embedding<Half> result = Assert.IsType<Embedding<Half>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding));
test\Shared\JsonSchemaExporter\TestTypes.cs (3)
71yield return new TestData<Half>((Half)3.141, """{"type":"number"}"""); 1216[JsonSerializable(typeof(Half))]
Microsoft.Extensions.AI.Integration.Tests (7)
EmbeddingGeneratorIntegrationTests.cs (2)
186using IEmbeddingGenerator<string, Embedding<Half>> generator = 193var distances = new Half[embeddings.Count, embeddings.Count];
QuantizationEmbeddingGenerator.cs (5)
19, IEmbeddingGenerator<string, Embedding<Half>> 68async Task<GeneratedEmbeddings<Embedding<Half>>> IEmbeddingGenerator<string, Embedding<Half>>.GenerateAsync( 79private static Embedding<Half> QuantizeToHalf(Embedding<float> embedding) 82var result = new Half[vector.Length];
System.Collections.Immutable (1)
System\Collections\Frozen\Constants.cs (1)
66typeof(T) == typeof(Half) ||
System.ComponentModel.TypeConverter (4)
System\ComponentModel\HalfConverter.cs (3)
23internal override Type TargetType => typeof(Half); 33internal override object FromString(string value, NumberFormatInfo? formatInfo) => Half.Parse(value, formatInfo); 39((Half)value).ToString(formatInfo);
System\ComponentModel\ReflectTypeDescriptionProvider.cs (1)
165[typeof(Half)] = new IntrinsicTypeConverterData((type) => new HalfConverter()),
System.Formats.Cbor (11)
System\Formats\Cbor\CborHelpers.netcoreapp.cs (1)
44public static Half ReadHalfBigEndian(ReadOnlySpan<byte> source)
System\Formats\Cbor\HalfHelpers.netcoreapp.cs (2)
11public static unsafe float HalfToFloat(Half value) 14public static unsafe double HalfToDouble(Half value)
System\Formats\Cbor\Reader\CborReader.Simple.netcoreapp.cs (2)
22public Half ReadHalf() 26Half result;
System\Formats\Cbor\Writer\CborWriter.Simple.cs (2)
26TryConvertSingleToHalf(value, out var half)) 48if (TryConvertSingleToHalf(single, out var half))
System\Formats\Cbor\Writer\CborWriter.Simple.netcoreapp.cs (4)
20public void WriteHalf(Half value) 24if (Half.IsNaN(value) && !CborConformanceModeHelpers.RequiresPreservingFloatPrecision(ConformanceMode)) 37internal static bool TryConvertSingleToHalf(float value, out Half result) 39result = (Half)value;
System.Numerics.Tensors (8)
System\Numerics\Tensors\netcore\TensorPrimitives.ConvertHelpers.cs (5)
128if (typeof(TFrom) == typeof(Half)) 139if (typeof(TTo) == typeof(Half)) 392public static float Invoke(short x) => (float)Unsafe.BitCast<short, Half>(x); 573public static ushort Invoke(float x) => Unsafe.BitCast<Half, ushort>((Half)x);
System\Numerics\Tensors\netcore\TensorPrimitives.Half.cs (2)
23public static void ConvertToHalf(ReadOnlySpan<float> source, Span<Half> destination) => 41public static void ConvertToSingle(ReadOnlySpan<Half> source, Span<float> destination) =>
System\Numerics\Tensors\TensorPrimitives.Helpers.cs (1)
88typeof(T) == typeof(Half) ||
System.Private.CoreLib (729)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (12)
315public static unsafe byte[] GetBytes(Half value) 317byte[] bytes = new byte[sizeof(Half)]; 329public static unsafe bool TryWriteBytes(Span<byte> destination, Half value) 331if (destination.Length < sizeof(Half)) 704public static Half ToHalf(byte[] value, int startIndex) => Int16BitsToHalf(ToInt16(value, startIndex)); 713public static unsafe Half ToHalf(ReadOnlySpan<byte> value) 715if (value.Length < sizeof(Half)) 717return Unsafe.ReadUnaligned<Half>(ref MemoryMarshal.GetReference(value)); 940public static short HalfToInt16Bits(Half value) => (short)value._value; 948public static Half Int16BitsToHalf(short value) => new Half((ushort)(value)); 993public static ushort HalfToUInt16Bits(Half value) => value._value; 1002public static Half UInt16BitsToHalf(ushort value) => new Half(value);
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReadBigEndian.cs (7)
29/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as big endian. 35/// <paramref name="source"/> is too small to contain a <see cref="Half" />. 38public static Half ReadHalfBigEndian(ReadOnlySpan<byte> source) 42MemoryMarshal.Read<Half>(source); 260/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as big endian. 265/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 269public static bool TryReadHalfBigEndian(ReadOnlySpan<byte> source, out Half value)
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReadLittleEndian.cs (7)
29/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as little endian. 35/// <paramref name="source"/> is too small to contain a <see cref="Half" />. 38public static Half ReadHalfLittleEndian(ReadOnlySpan<byte> source) 42MemoryMarshal.Read<Half>(source); 260/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as little endian. 265/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 269public static bool TryReadHalfLittleEndian(ReadOnlySpan<byte> source, out Half value)
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.WriteBigEndian.cs (6)
35/// Writes a <see cref="Half" /> into a span of bytes, as big endian. 41/// <paramref name="destination" /> is too small to contain a <see cref="Half" />. 44public static void WriteHalfBigEndian(Span<byte> destination, Half value) 337/// Writes a <see cref="Half" /> into a span of bytes, as big endian. 342/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 346public static bool TryWriteHalfBigEndian(Span<byte> destination, Half value)
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.WriteLittleEndian.cs (6)
35/// Writes a <see cref="Half" /> into a span of bytes, as little endian. 41/// <paramref name="destination" /> is too small to contain a <see cref="Half" />. 44public static void WriteHalfLittleEndian(Span<byte> destination, Half value) 337/// Writes a <see cref="Half" /> into a span of bytes, as little endian. 342/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 346public static bool TryWriteHalfLittleEndian(Span<byte> destination, Half value)
src\libraries\System.Private.CoreLib\src\System\Byte.cs (6)
903else if (typeof(TOther) == typeof(Half)) 905Half actualResult = value; 977else if (typeof(TOther) == typeof(Half)) 979Half actualResult = value; 1051else if (typeof(TOther) == typeof(Half)) 1053Half actualResult = value;
src\libraries\System.Private.CoreLib\src\System\Char.cs (9)
1716else if (typeof(TOther) == typeof(Half)) 1718Half actualResult = (Half)value; 1790else if (typeof(TOther) == typeof(Half)) 1792Half actualResult = (Half)value; 1864else if (typeof(TOther) == typeof(Half)) 1866Half actualResult = (Half)value;
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs (17)
296typeof(T) == typeof(Half)) 585if (typeof(T) == typeof(Half)) return (Half)(object)left < (Half)(object)right; 604if (typeof(T) == typeof(Half)) return (Half)(object)left > (Half)(object)right; 847typeof(TKey) == typeof(Half)) 1082if (typeof(TKey) == typeof(Half)) return (Half)(object)left < (Half)(object)right; 1101if (typeof(TKey) == typeof(Half)) return (Half)(object)left > (Half)(object)right; 1121(typeof(TKey) == typeof(Half) && Half.IsNaN((Half)(object)keys[i])))
src\libraries\System.Private.CoreLib\src\System\Decimal.cs (6)
1657else if (typeof(TOther) == typeof(Half)) 1659Half actualResult = checked((Half)value); 1745else if (typeof(TOther) == typeof(Half)) 1747Half actualResult = (Half)value;
src\libraries\System.Private.CoreLib\src\System\Double.cs (3)
1242if (typeof(TOther) == typeof(Half)) 1244Half actualValue = (Half)(object)value;
src\libraries\System.Private.CoreLib\src\System\Half.cs (533)
23IComparable<Half>, 24IEquatable<Half>, 25IBinaryFloatingPointIeee754<Half>, 26IMinMaxValue<Half>, 28IBinaryFloatParseAndFormatInfo<Half> 89public static Half Epsilon => new Half(EpsilonBits); // 5.9604645E-08 91public static Half PositiveInfinity => new Half(PositiveInfinityBits); // 1.0 / 0.0; 93public static Half NegativeInfinity => new Half(NegativeInfinityBits); // -1.0 / 0.0 95public static Half NaN => new Half(NegativeQNaNBits); // 0.0 / 0.0 98public static Half MinValue => new Half(MinValueBits); // -65504 101public static Half MaxValue => new Half(MaxValueBits); // 65504 157public static bool operator <(Half left, Half right) 179public static bool operator >(Half left, Half right) 185public static bool operator <=(Half left, Half right) 207public static bool operator >=(Half left, Half right) 213public static bool operator ==(Half left, Half right) 226public static bool operator !=(Half left, Half right) 234public static bool IsFinite(Half value) 242public static bool IsInfinity(Half value) 250public static bool IsNaN(Half value) 257internal static bool IsNaNOrZero(Half value) 265public static bool IsNegative(Half value) 272public static bool IsNegativeInfinity(Half value) 280public static bool IsNormal(Half value) 288public static bool IsPositiveInfinity(Half value) 296public static bool IsSubnormal(Half value) 303internal static bool IsZero(Half value) 310/// Parses a <see cref="Half"/> from a <see cref="string"/> in the default parse style. 313/// <returns>The equivalent <see cref="Half"/> value representing the input string. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns> 314public static Half Parse(string s) => Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null); 317/// Parses a <see cref="Half"/> from a <see cref="string"/> in the given <see cref="NumberStyles"/>. 321/// <returns>The equivalent <see cref="Half"/> value representing the input string. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns> 322public static Half Parse(string s, NumberStyles style) => Parse(s, style, provider: null); 325/// Parses a <see cref="Half"/> from a <see cref="string"/> and <see cref="IFormatProvider"/>. 329/// <returns>The equivalent <see cref="Half"/> value representing the input string. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns> 330public static Half Parse(string s, IFormatProvider? provider) => Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider); 333/// Parses a <see cref="Half"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>. 338/// <returns>The equivalent <see cref="Half"/> value representing the input string. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns> 339public static Half Parse(string s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null) 349/// Parses a <see cref="Half"/> from a <see cref="ReadOnlySpan{Char}"/> and <see cref="IFormatProvider"/>. 354/// <returns>The equivalent <see cref="Half"/> value representing the input string. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. </returns> 355public static Half Parse(ReadOnlySpan<char> s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null) 358return Number.ParseFloat<char, Half>(s, style, NumberFormatInfo.GetInstance(provider)); 362/// Tries to parse a <see cref="Half"/> from a <see cref="string"/> in the default parse style. 365/// <param name="result">The equivalent <see cref="Half"/> value representing the input string if the parse was successful. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="Half"/> value is returned.</param> 367public static bool TryParse([NotNullWhen(true)] string? s, out Half result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result); 370/// Tries to parse a <see cref="Half"/> from a <see cref="ReadOnlySpan{Char}"/> in the default parse style. 373/// <param name="result">The equivalent <see cref="Half"/> value representing the input string if the parse was successful. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="Half"/> value is returned.</param> 375public static bool TryParse(ReadOnlySpan<char> s, out Half result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result); 381public static bool TryParse(ReadOnlySpan<byte> utf8Text, out Half result) => TryParse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result); 384/// Tries to parse a <see cref="Half"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>. 389/// <param name="result">The equivalent <see cref="Half"/> value representing the input string if the parse was successful. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="Half"/> value is returned.</param> 391public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out Half result) 404/// Tries to parse a <see cref="Half"/> from a <see cref="ReadOnlySpan{Char}"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>. 409/// <param name="result">The equivalent <see cref="Half"/> value representing the input string if the parse was successful. If the input exceeds Half's range, a <see cref="PositiveInfinity"/> or <see cref="NegativeInfinity"/> is returned. If the parse was unsuccessful, a default <see cref="Half"/> value is returned.</param> 411public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out Half result) 417private static bool AreZero(Half left, Half right) 429/// <exception cref="ArgumentException">Thrown when <paramref name="obj"/> is not of type <see cref="Half"/>.</exception> 432if (obj is not Half other) 443public int CompareTo(Half other) 474return (obj is Half other) && Equals(other); 480public bool Equals(Half other) 561public static explicit operator Half(char value) => (Half)(float)value; 566public static explicit operator Half(decimal value) => (Half)(float)value; 571public static explicit operator Half(double value) 600public static explicit operator Half(short value) => (Half)(float)value; 605public static explicit operator Half(int value) => (Half)(float)value; 610public static explicit operator Half(long value) => (Half)(float)value; 615public static explicit operator Half(nint value) => (Half)(float)value; 620public static explicit operator Half(float value) 787public static explicit operator Half(ushort value) => (Half)(float)value; 793public static explicit operator Half(uint value) => (Half)(float)value; 799public static explicit operator Half(ulong value) => (Half)(float)value; 805public static explicit operator Half(nuint value) => (Half)(float)value; 814public static explicit operator byte(Half value) => (byte)(float)value; 820public static explicit operator checked byte(Half value) => checked((byte)(float)value); 825public static explicit operator char(Half value) => (char)(float)value; 831public static explicit operator checked char(Half value) => checked((char)(float)value); 836public static explicit operator decimal(Half value) => (decimal)(float)value; 841public static explicit operator short(Half value) => (short)(float)value; 847public static explicit operator checked short(Half value) => checked((short)(float)value); 852public static explicit operator int(Half value) => (int)(float)value; 858public static explicit operator checked int(Half value) => checked((int)(float)value); 863public static explicit operator long(Half value) => (long)(float)value; 869public static explicit operator checked long(Half value) => checked((long)(float)value); 874public static explicit operator Int128(Half value) => (Int128)(double)(value); 880public static explicit operator checked Int128(Half value) => checked((Int128)(double)(value)); 885public static explicit operator nint(Half value) => (nint)(float)value; 891public static explicit operator checked nint(Half value) => checked((nint)(float)value); 897public static explicit operator sbyte(Half value) => (sbyte)(float)value; 904public static explicit operator checked sbyte(Half value) => checked((sbyte)(float)value); 910public static explicit operator ushort(Half value) => (ushort)(float)value; 917public static explicit operator checked ushort(Half value) => checked((ushort)(float)value); 923public static explicit operator uint(Half value) => (uint)(float)value; 930public static explicit operator checked uint(Half value) => checked((uint)(float)value); 936public static explicit operator ulong(Half value) => (ulong)(float)value; 943public static explicit operator checked ulong(Half value) => checked((ulong)(float)value); 949public static explicit operator UInt128(Half value) => (UInt128)(double)(value); 956public static explicit operator checked UInt128(Half value) => checked((UInt128)(double)(value)); 962public static explicit operator nuint(Half value) => (nuint)(float)value; 969public static explicit operator checked nuint(Half value) => checked((nuint)(float)value); 978public static implicit operator Half(byte value) => (Half)(float)value; 984public static implicit operator Half(sbyte value) => (Half)(float)value; 993public static explicit operator double(Half value) 1024public static explicit operator float(Half value) 1098internal static Half Negate(Half value) 1113private static Half CreateHalfNaN(bool sign, ulong significand) 1191public static Half operator +(Half left, Half right) => (Half)((float)left + (float)right); 1198static Half IAdditiveIdentity<Half, Half>.AdditiveIdentity => new Half(PositiveZeroBits); 1205static Half IBinaryNumber<Half>.AllBitsSet => BitConverter.UInt16BitsToHalf(0xFFFF); 1208public static bool IsPow2(Half value) 1237public static Half Log2(Half value) => (Half)MathF.Log2((float)value); 1244static Half IBitwiseOperators<Half, Half, Half>.operator &(Half left, Half right) 1250static Half IBitwiseOperators<Half, Half, Half>.operator |(Half left, Half right) 1256static Half IBitwiseOperators<Half, Half, Half>.operator ^(Half left, Half right) 1262static Half IBitwiseOperators<Half, Half, Half>.operator ~(Half value) 1272public static Half operator --(Half value) 1276return (Half)tmp; 1284public static Half operator /(Half left, Half right) => (Half)((float)left / (float)right); 1291public static Half Exp(Half x) => (Half)MathF.Exp((float)x); 1294public static Half ExpM1(Half x) => (Half)float.ExpM1((float)x); 1297public static Half Exp2(Half x) => (Half)float.Exp2((float)x); 1300public static Half Exp2M1(Half x) => (Half)float.Exp2M1((float)x); 1303public static Half Exp10(Half x) => (Half)float.Exp10((float)x); 1306public static Half Exp10M1(Half x) => (Half)float.Exp10M1((float)x); 1313public static Half Ceiling(Half x) => (Half)MathF.Ceiling((float)x); 1316public static TInteger ConvertToInteger<TInteger>(Half value) 1320public static TInteger ConvertToIntegerNative<TInteger>(Half value) 1324public static Half Floor(Half x) => (Half)MathF.Floor((float)x); 1327public static Half Round(Half x) => (Half)MathF.Round((float)x); 1330public static Half Round(Half x, int digits) => (Half)MathF.Round((float)x, digits); 1333public static Half Round(Half x, MidpointRounding mode) => (Half)MathF.Round((float)x, mode); 1336public static Half Round(Half x, int digits, MidpointRounding mode) => (Half)MathF.Round((float)x, digits, mode); 1339public static Half Truncate(Half x) => (Half)MathF.Truncate((float)x); 1342int IFloatingPoint<Half>.GetExponentByteCount() => sizeof(sbyte); 1345int IFloatingPoint<Half>.GetExponentShortestBitLength() 1360int IFloatingPoint<Half>.GetSignificandByteCount() => sizeof(ushort); 1363int IFloatingPoint<Half>.GetSignificandBitLength() => 11; 1366bool IFloatingPoint<Half>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten) 1380bool IFloatingPoint<Half>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten) 1394bool IFloatingPoint<Half>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten) 1407bool IFloatingPoint<Half>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten) 1424public static Half E => new Half(EBits); 1427public static Half Pi => new Half(PiBits); 1430public static Half Tau => new Half(TauBits); 1437public static Half NegativeZero => new Half(NegativeZeroBits); 1440public static Half Atan2(Half y, Half x) => (Half)MathF.Atan2((float)y, (float)x); 1443public static Half Atan2Pi(Half y, Half x) => (Half)float.Atan2Pi((float)y, (float)x); 1446public static Half BitDecrement(Half x) 1479public static Half BitIncrement(Half x) 1512public static Half FusedMultiplyAdd(Half left, Half right, Half addend) => (Half)MathF.FusedMultiplyAdd((float)left, (float)right, (float)addend); 1515public static Half Ieee754Remainder(Half left, Half right) => (Half)MathF.IEEERemainder((float)left, (float)right); 1518public static int ILogB(Half x) 1546public static Half Lerp(Half value1, Half value2, Half amount) => (Half)float.Lerp((float)value1, (float)value2, (float)amount); 1549public static Half ReciprocalEstimate(Half x) => (Half)MathF.ReciprocalEstimate((float)x); 1552public static Half ReciprocalSqrtEstimate(Half x) => (Half)MathF.ReciprocalSqrtEstimate((float)x); 1555public static Half ScaleB(Half x, int n) => (Half)MathF.ScaleB((float)x, n); 1565public static Half Acosh(Half x) => (Half)MathF.Acosh((float)x); 1568public static Half Asinh(Half x) => (Half)MathF.Asinh((float)x); 1571public static Half Atanh(Half x) => (Half)MathF.Atanh((float)x); 1574public static Half Cosh(Half x) => (Half)MathF.Cosh((float)x); 1577public static Half Sinh(Half x) => (Half)MathF.Sinh((float)x); 1580public static Half Tanh(Half x) => (Half)MathF.Tanh((float)x); 1587public static Half operator ++(Half value) 1591return (Half)tmp; 1599public static Half Log(Half x) => (Half)MathF.Log((float)x); 1602public static Half Log(Half x, Half newBase) => (Half)MathF.Log((float)x, (float)newBase); 1605public static Half Log10(Half x) => (Half)MathF.Log10((float)x); 1608public static Half LogP1(Half x) => (Half)float.LogP1((float)x); 1611public static Half Log2P1(Half x) => (Half)float.Log2P1((float)x); 1614public static Half Log10P1(Half x) => (Half)float.Log10P1((float)x); 1621public static Half operator %(Half left, Half right) => (Half)((float)left % (float)right); 1628public static Half MultiplicativeIdentity => new Half(PositiveOneBits); 1635public static Half operator *(Half left, Half right) => (Half)((float)left * (float)right); 1642public static Half Clamp(Half value, Half min, Half max) => (Half)float.Clamp((float)value, (float)min, (float)max); 1645public static Half ClampNative(Half value, Half min, Half max) 1655public static Half CopySign(Half value, Half sign) 1668public static Half Max(Half x, Half y) => (Half)float.Max((float)x, (float)y); 1671public static Half MaxNative(Half x, Half y) => (x > y) ? x : y; 1674public static Half MaxNumber(Half x, Half y) 1696public static Half Min(Half x, Half y) => (Half)float.Min((float)x, (float)y); 1699public static Half MinNative(Half x, Half y) => (x < y) ? x : y; 1702public static Half MinNumber(Half x, Half y) 1724public static int Sign(Half value) 1748public static Half One => new Half(PositiveOneBits); 1751static int INumberBase<Half>.Radix => 2; 1754public static Half Zero => new Half(PositiveZeroBits); 1757public static Half Abs(Half value) => new Half((ushort)(value._value & ~SignMask)); 1761public static Half CreateChecked<TOther>(TOther value) 1764Half result; 1766if (typeof(TOther) == typeof(Half)) 1768result = (Half)(object)value; 1780public static Half CreateSaturating<TOther>(TOther value) 1783Half result; 1785if (typeof(TOther) == typeof(Half)) 1787result = (Half)(object)value; 1799public static Half CreateTruncating<TOther>(TOther value) 1802Half result; 1804if (typeof(TOther) == typeof(Half)) 1806result = (Half)(object)value; 1817static bool INumberBase<Half>.IsCanonical(Half value) => true; 1820static bool INumberBase<Half>.IsComplexNumber(Half value) => false; 1823public static bool IsEvenInteger(Half value) => float.IsEvenInteger((float)value); 1826static bool INumberBase<Half>.IsImaginaryNumber(Half value) => false; 1829public static bool IsInteger(Half value) => float.IsInteger((float)value); 1832public static bool IsOddInteger(Half value) => float.IsOddInteger((float)value); 1835public static bool IsPositive(Half value) => (short)(value._value) >= 0; 1838public static bool IsRealNumber(Half value) 1849static bool INumberBase<Half>.IsZero(Half value) => IsZero(value); 1852public static Half MaxMagnitude(Half x, Half y) => (Half)MathF.MaxMagnitude((float)x, (float)y); 1855public static Half MaxMagnitudeNumber(Half x, Half y) 1863Half ax = Abs(x); 1864Half ay = Abs(y); 1880public static Half MinMagnitude(Half x, Half y) => (Half)MathF.MinMagnitude((float)x, (float)y); 1883public static Half MinMagnitudeNumber(Half x, Half y) 1891Half ax = Abs(x); 1892Half ay = Abs(y); 1908public static Half MultiplyAddEstimate(Half left, Half right, Half addend) => (Half)float.MultiplyAddEstimate((float)left, (float)right, (float)addend); 1912static bool INumberBase<Half>.TryConvertFromChecked<TOther>(TOther value, out Half result) 1919static bool INumberBase<Half>.TryConvertFromSaturating<TOther>(TOther value, out Half result) 1926static bool INumberBase<Half>.TryConvertFromTruncating<TOther>(TOther value, out Half result) 1932private static bool TryConvertFrom<TOther>(TOther value, out Half result) 1947result = (Half)actualValue; 1953result = (Half)actualValue; 1959result = (Half)actualValue; 1965result = (Half)actualValue; 1971result = (Half)actualValue; 1977result = (Half)actualValue; 1989result = (Half)actualValue; 2001static bool INumberBase<Half>.TryConvertToChecked<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2069static bool INumberBase<Half>.TryConvertToSaturating<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2076static bool INumberBase<Half>.TryConvertToTruncating<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2082private static bool TryConvertTo<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2164public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out Half result) => TryParse(s, DefaultParseStyle, provider, out result); 2171public static Half Pow(Half x, Half y) => (Half)MathF.Pow((float)x, (float)y); 2178public static Half Cbrt(Half x) => (Half)MathF.Cbrt((float)x); 2181public static Half Hypot(Half x, Half y) => (Half)float.Hypot((float)x, (float)y); 2184public static Half RootN(Half x, int n) => (Half)float.RootN((float)x, n); 2187public static Half Sqrt(Half x) => (Half)MathF.Sqrt((float)x); 2194public static Half NegativeOne => new Half(NegativeOneBits); 2201public static Half Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, DefaultParseStyle, provider); 2204public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out Half result) => TryParse(s, DefaultParseStyle, provider, out result); 2211public static Half operator -(Half left, Half right) => (Half)((float)left - (float)right); 2218public static Half Acos(Half x) => (Half)MathF.Acos((float)x); 2221public static Half AcosPi(Half x) => (Half)float.AcosPi((float)x); 2224public static Half Asin(Half x) => (Half)MathF.Asin((float)x); 2227public static Half AsinPi(Half x) => (Half)float.AsinPi((float)x); 2230public static Half Atan(Half x) => (Half)MathF.Atan((float)x); 2233public static Half AtanPi(Half x) => (Half)float.AtanPi((float)x); 2236public static Half Cos(Half x) => (Half)MathF.Cos((float)x); 2239public static Half CosPi(Half x) => (Half)float.CosPi((float)x); 2242public static Half DegreesToRadians(Half degrees) 2247return (Half)float.DegreesToRadians((float)degrees); 2251public static Half RadiansToDegrees(Half radians) 2256return (Half)float.RadiansToDegrees((float)radians); 2260public static Half Sin(Half x) => (Half)MathF.Sin((float)x); 2263public static (Half Sin, Half Cos) SinCos(Half x) 2266return ((Half)sin, (Half)cos); 2270public static (Half SinPi, Half CosPi) SinCosPi(Half x) 2273return ((Half)sinPi, (Half)cosPi); 2277public static Half SinPi(Half x) => (Half)float.SinPi((float)x); 2280public static Half Tan(Half x) => (Half)MathF.Tan((float)x); 2283public static Half TanPi(Half x) => (Half)float.TanPi((float)x); 2290public static Half operator -(Half value) => (Half)(-(float)value); 2297public static Half operator +(Half value) => value; 2304public static Half Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = NumberStyles.Float | NumberStyles.AllowThousands, IFormatProvider? provider = null) 2307return Number.ParseFloat<byte, Half>(utf8Text, style, NumberFormatInfo.GetInstance(provider)); 2311public static bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out Half result) 2318public static Half Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider); 2321public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Half result) => TryParse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider, out result); 2327static int IBinaryFloatParseAndFormatInfo<Half>.NumberBufferLength => Number.HalfNumberBufferLength; 2329static ulong IBinaryFloatParseAndFormatInfo<Half>.ZeroBits => 0; 2330static ulong IBinaryFloatParseAndFormatInfo<Half>.InfinityBits => 0x7C00; 2332static ulong IBinaryFloatParseAndFormatInfo<Half>.NormalMantissaMask => (1UL << SignificandLength) - 1; 2333static ulong IBinaryFloatParseAndFormatInfo<Half>.DenormalMantissaMask => TrailingSignificandMask; 2335static int IBinaryFloatParseAndFormatInfo<Half>.MinBinaryExponent => 1 - MaxExponent; 2336static int IBinaryFloatParseAndFormatInfo<Half>.MaxBinaryExponent => MaxExponent; 2338static int IBinaryFloatParseAndFormatInfo<Half>.MinDecimalExponent => -8; 2339static int IBinaryFloatParseAndFormatInfo<Half>.MaxDecimalExponent => 5; 2341static int IBinaryFloatParseAndFormatInfo<Half>.ExponentBias => ExponentBias; 2342static ushort IBinaryFloatParseAndFormatInfo<Half>.ExponentBits => 5; 2344static int IBinaryFloatParseAndFormatInfo<Half>.OverflowDecimalExponent => (MaxExponent + (2 * SignificandLength)) / 3; 2345static int IBinaryFloatParseAndFormatInfo<Half>.InfinityExponent => 0x1F; 2347static ushort IBinaryFloatParseAndFormatInfo<Half>.NormalMantissaBits => SignificandLength; 2348static ushort IBinaryFloatParseAndFormatInfo<Half>.DenormalMantissaBits => TrailingSignificandLength; 2350static int IBinaryFloatParseAndFormatInfo<Half>.MinFastFloatDecimalExponent => -8; 2351static int IBinaryFloatParseAndFormatInfo<Half>.MaxFastFloatDecimalExponent => 4; 2353static int IBinaryFloatParseAndFormatInfo<Half>.MinExponentRoundToEven => -21; 2354static int IBinaryFloatParseAndFormatInfo<Half>.MaxExponentRoundToEven => 5; 2356static int IBinaryFloatParseAndFormatInfo<Half>.MaxExponentFastPath => 4; 2357static ulong IBinaryFloatParseAndFormatInfo<Half>.MaxMantissaFastPath => 2UL << TrailingSignificandLength; 2359static Half IBinaryFloatParseAndFormatInfo<Half>.BitsToFloat(ulong bits) => BitConverter.UInt16BitsToHalf((ushort)(bits)); 2361static ulong IBinaryFloatParseAndFormatInfo<Half>.FloatToBits(Half value) => BitConverter.HalfToUInt16Bits(value); 2363static int IBinaryFloatParseAndFormatInfo<Half>.MaxRoundTripDigits => 5; 2365static int IBinaryFloatParseAndFormatInfo<Half>.MaxPrecisionCustomFormat => 5;
src\libraries\System.Private.CoreLib\src\System\Int16.cs (9)
895else if (typeof(TOther) == typeof(Half)) 897Half actualValue = (Half)(object)value; 968else if (typeof(TOther) == typeof(Half)) 970Half actualValue = (Half)(object)value; 1047else if (typeof(TOther) == typeof(Half)) 1049Half actualValue = (Half)(object)value;
src\libraries\System.Private.CoreLib\src\System\Int32.cs (13)
936else if (typeof(TOther) == typeof(Half)) 938Half actualValue = (Half)(object)value; 1009else if (typeof(TOther) == typeof(Half)) 1011Half actualValue = (Half)(object)value; 1012result = (actualValue == Half.PositiveInfinity) ? MaxValue : 1013(actualValue == Half.NegativeInfinity) ? MinValue : (int)actualValue; 1087else if (typeof(TOther) == typeof(Half)) 1089Half actualValue = (Half)(object)value; 1090result = (actualValue == Half.PositiveInfinity) ? MaxValue : 1091(actualValue == Half.NegativeInfinity) ? MinValue : (int)actualValue;
src\libraries\System.Private.CoreLib\src\System\Int64.cs (13)
933else if (typeof(TOther) == typeof(Half)) 935Half actualValue = (Half)(object)value; 1006else if (typeof(TOther) == typeof(Half)) 1008Half actualValue = (Half)(object)value; 1009result = (actualValue == Half.PositiveInfinity) ? MaxValue : 1010(actualValue == Half.NegativeInfinity) ? MinValue : (long)actualValue; 1082else if (typeof(TOther) == typeof(Half)) 1084Half actualValue = (Half)(object)value; 1085result = (actualValue == Half.PositiveInfinity) ? MaxValue : 1086(actualValue == Half.NegativeInfinity) ? MinValue : (long)actualValue;
src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (13)
928else if (typeof(TOther) == typeof(Half)) 930Half actualValue = (Half)(object)value; 1001else if (typeof(TOther) == typeof(Half)) 1003Half actualValue = (Half)(object)value; 1004result = (actualValue == Half.PositiveInfinity) ? unchecked((nint)nint_t.MaxValue) : 1005(actualValue == Half.NegativeInfinity) ? unchecked((nint)nint_t.MinValue) : (nint)actualValue; 1078else if (typeof(TOther) == typeof(Half)) 1080Half actualValue = (Half)(object)value; 1081result = (actualValue == Half.PositiveInfinity) ? unchecked((nint)nint_t.MaxValue) : 1082(actualValue == Half.NegativeInfinity) ? unchecked((nint)nint_t.MinValue) : (nint)actualValue;
src\libraries\System.Private.CoreLib\src\System\IO\BinaryReader.cs (2)
225public virtual unsafe Half ReadHalf() => BinaryPrimitives.ReadHalfLittleEndian(InternalRead(stackalloc byte[sizeof(Half)]));
src\libraries\System.Private.CoreLib\src\System\IO\BinaryWriter.cs (1)
334public virtual void Write(Half value)
src\libraries\System.Private.CoreLib\src\System\Numerics\TotalOrderIeee754Comparer.cs (3)
61else if (typeof(T) == typeof(Half)) 63return CompareIntegerSemantic(BitConverter.HalfToInt16Bits((Half)(object)x!), BitConverter.HalfToInt16Bits((Half)(object)y!));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NFloat.cs (15)
284/// <summary>Explicitly converts a native-sized floating-point value to its nearest representable <see cref="Half" /> value.</summary> 286/// <returns><paramref name="value" /> converted to its nearest representable <see cref="Half" /> value.</returns> 288public static explicit operator Half(NFloat value) => (Half)(value._value); 467/// <summary>Implicitly converts a <see cref="Half" /> value to its nearest representable native-sized floating-point value.</summary> 471public static implicit operator NFloat(Half value) => (NFloat)(float)value; 1441else if (typeof(TOther) == typeof(Half)) 1443Half actualValue = (Half)(object)value; 1554else if (typeof(TOther) == typeof(Half)) 1556Half actualResult = (Half)value; 1685else if (typeof(TOther) == typeof(Half)) 1687Half actualResult = (Half)value;
src\libraries\System.Private.CoreLib\src\System\SByte.cs (9)
858else if (typeof(TOther) == typeof(Half)) 860Half actualValue = (Half)(object)value; 931else if (typeof(TOther) == typeof(Half)) 933Half actualValue = (Half)(object)value; 1011else if (typeof(TOther) == typeof(Half)) 1013Half actualValue = (Half)(object)value;
src\libraries\System.Private.CoreLib\src\System\Single.cs (3)
1267else if (typeof(TOther) == typeof(Half)) 1269Half actualValue = (Half)(object)value;
src\libraries\System.Private.CoreLib\src\System\UInt16.cs (9)
922else if (typeof(TOther) == typeof(Half)) 924Half actualResult = (Half)value; 996else if (typeof(TOther) == typeof(Half)) 998Half actualResult = (Half)value; 1070else if (typeof(TOther) == typeof(Half)) 1072Half actualResult = (Half)value;
src\libraries\System.Private.CoreLib\src\System\UInt32.cs (9)
961else if (typeof(TOther) == typeof(Half)) 963Half actualResult = (Half)value; 1035else if (typeof(TOther) == typeof(Half)) 1037Half actualResult = (Half)value; 1115else if (typeof(TOther) == typeof(Half)) 1117Half actualResult = (Half)value;
src\libraries\System.Private.CoreLib\src\System\UInt64.cs (9)
960else if (typeof(TOther) == typeof(Half)) 962Half actualResult = (Half)value; 1034else if (typeof(TOther) == typeof(Half)) 1036Half actualResult = (Half)value; 1108else if (typeof(TOther) == typeof(Half)) 1110Half actualResult = (Half)value;
src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (9)
963else if (typeof(TOther) == typeof(Half)) 965Half actualResult = (Half)value; 1037else if (typeof(TOther) == typeof(Half)) 1039Half actualResult = (Half)value; 1111else if (typeof(TOther) == typeof(Half)) 1113Half actualResult = (Half)value;
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
261[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Half))]
System.Runtime.Numerics (41)
System\Numerics\BigInteger.cs (26)
1860/// <summary>Explicitly converts a big integer to a <see cref="Half" /> value.</summary> 1862/// <returns><paramref name="value" /> converted to <see cref="Half" /> value.</returns> 1863public static explicit operator Half(BigInteger value) 1865return (Half)(double)value; 2113/// <summary>Explicitly converts a <see cref="Half" /> value to a big integer.</summary> 2116public static explicit operator BigInteger(Half value) 4218else if (typeof(TOther) == typeof(Half)) 4220Half actualValue = (Half)(object)value; 4335else if (typeof(TOther) == typeof(Half)) 4337Half actualValue = (Half)(object)value; 4338result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue; 4452else if (typeof(TOther) == typeof(Half)) 4454Half actualValue = (Half)(object)value; 4455result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue; 4565else if (typeof(TOther) == typeof(Half)) 4567Half actualResult = (Half)value; 4707else if (typeof(TOther) == typeof(Half)) 4709Half actualResult = (Half)value; 4912else if (typeof(TOther) == typeof(Half)) 4914Half actualResult = (Half)value;
System\Numerics\Complex.cs (15)
827/// <summary>Implicitly converts a <see cref="Half" /> value to a double-precision complex number.</summary> 830public static implicit operator Complex(Half value) 1525else if (typeof(TOther) == typeof(Half)) 1527Half actualValue = (Half)(object)value; 1658else if (typeof(TOther) == typeof(Half)) 1660Half actualResult = (value.m_imaginary != 0) ? Half.NaN : (Half)value.m_real; 1851else if (typeof(TOther) == typeof(Half)) 1853Half actualResult = (Half)value.m_real; 1987else if (typeof(TOther) == typeof(Half)) 1989Half actualResult = (Half)value.m_real;
System.Text.Json (35)
System\Text\Json\Nodes\JsonValueOfT.cs (1)
102if (type == typeof(Half) || type == typeof(UInt128) || type == typeof(Int128))
System\Text\Json\Reader\JsonReaderHelper.cs (4)
149public static bool TryGetFloatingPointConstant(ReadOnlySpan<byte> span, out Half value) 155value = Half.NaN; 163value = Half.PositiveInfinity; 171value = Half.NegativeInfinity;
System\Text\Json\Serialization\Converters\Value\HalfConverter.cs (25)
12internal sealed class HalfConverter : JsonPrimitiveConverter<Half> 21public override Half Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 31public override void Write(Utf8JsonWriter writer, Half value, JsonSerializerOptions options) 36private static Half ReadCore(ref Utf8JsonReader reader) 38Half result; 61Debug.Assert(!Half.IsNaN(result) && !Half.IsInfinity(result)); 65private static void WriteCore(Utf8JsonWriter writer, Half value) 72internal override Half ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 78internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Half value, JsonSerializerOptions options, bool isWritingExtensionDataProperty) 85internal override Half ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options) 91if (TryGetFloatingPointConstant(ref reader, out Half value)) 100if (!TryGetFloatingPointConstant(ref reader, out Half value)) 112internal override void WriteNumberWithCustomHandling(Utf8JsonWriter writer, Half value, JsonNumberHandling handling) 138private static bool TryGetFloatingPointConstant(ref Utf8JsonReader reader, out Half value) 146private static void WriteFloatingPointConstant(Utf8JsonWriter writer, Half value) 148if (Half.IsNaN(value)) 152else if (Half.IsPositiveInfinity(value)) 156else if (Half.IsNegativeInfinity(value)) 166private static bool TryParse(ReadOnlySpan<byte> buffer, out Half result) 168bool success = Half.TryParse(buffer, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result); 173(!Half.IsNaN(result) || buffer.SequenceEqual(JsonConstants.NaNValue)) && 174(!Half.IsPositiveInfinity(result) || buffer.SequenceEqual(JsonConstants.PositiveInfinityValue)) && 175(!Half.IsNegativeInfinity(result) || buffer.SequenceEqual(JsonConstants.NegativeInfinityValue)); 180Half value, out int written)
System\Text\Json\Serialization\Converters\Value\JsonPrimitiveConverter.cs (1)
38Debug.Assert(isIeeeFloatingPoint == (typeof(T) == typeof(double) || typeof(T) == typeof(float) || typeof(T) == typeof(Half)));
System\Text\Json\Serialization\Metadata\JsonMetadataServices.Converters.cs (3)
193/// Returns a <see cref="JsonConverter{T}"/> instance that converts <see cref="Half"/> values. 196public static JsonConverter<Half> HalfConverter => s_halfConverter ??= new HalfConverter(); 197private static JsonConverter<Half>? s_halfConverter;
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (1)
727potentialNumberType == typeof(Half) ||