29 instantiations of Half
System.Private.CoreLib (29)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (2)
949public static Half Int16BitsToHalf(short value) => new Half((ushort)(value)); 1007public 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; 1194static Half IAdditiveIdentity<Half, Half>.AdditiveIdentity => new Half(PositiveZeroBits); 1242return new Half((ushort)(left._value & right._value)); 1248return new Half((ushort)(left._value | right._value)); 1254return new Half((ushort)(left._value ^ right._value)); 1260return new Half((ushort)(~value._value)); 1420public static Half E => new Half(EBits); 1423public static Half Pi => new Half(PiBits); 1426public static Half Tau => new Half(TauBits); 1433public static Half NegativeZero => new Half(NegativeZeroBits); 1471return new Half((ushort)bits); 1504return new Half((ushort)bits); 1624public static Half MultiplicativeIdentity => new Half(PositiveOneBits); 1660return new Half((ushort)((xbits & ~SignMask) | (ybits & SignMask))); 1744public static Half One => new Half(PositiveOneBits); 1750public static Half Zero => new Half(PositiveZeroBits); 1753public static Half Abs(Half value) => new Half((ushort)(value._value & ~SignMask)); 2202public static Half NegativeOne => new Half(NegativeOneBits);
1167 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.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)
56typeof(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.Collections.Package (17)
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.Threading.Package (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.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)
68yield return new TestData<Half>((Half)3.141, """{"type":"number"}"""); 1228[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];
Shared.Tests (3)
JsonSchemaExporter\TestTypes.cs (3)
68yield return new TestData<Half>((Half)3.141, """{"type":"number"}"""); 1228[JsonSerializable(typeof(Half))]
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)
164[typeof(Half)] = new IntrinsicTypeConverterData((type) => new HalfConverter()),
System.Formats.Cbor (11)
System\Formats\Cbor\CborHelpers.netcoreapp.cs (1)
28public 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 (179)
System\Numerics\Tensors\netcore\TensorPrimitives.Abs.cs (1)
32if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, AbsoluteOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Add.cs (2)
29if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, AddOperator<float>>(x, y, destination)) 54if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, AddOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.AddMultiply.cs (3)
31if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, AddMultiplyOperator<float>>(x, y, multiplier, destination)) 59if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, AddMultiplyOperator<float>>(x, y, multiplier, destination)) 87if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, AddMultiplyOperator<float>>(x, y, multiplier, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.BitwiseAnd.cs (2)
26if (typeof(T) == typeof(Half) && TryBinaryBitwiseInvokeHalfAsInt16<T, BitwiseAndOperator<short>>(x, y, destination)) 48if (typeof(T) == typeof(Half) && TryBinaryBitwiseInvokeHalfAsInt16<T, BitwiseAndOperator<short>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.BitwiseOr.cs (2)
26if (typeof(T) == typeof(Half) && TryBinaryBitwiseInvokeHalfAsInt16<T, BitwiseOrOperator<short>>(x, y, destination)) 48if (typeof(T) == typeof(Half) && TryBinaryBitwiseInvokeHalfAsInt16<T, BitwiseOrOperator<short>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Ceiling.cs (1)
24if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, CeilingOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Clamp.cs (7)
33if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination)) 62if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination)) 91if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination)) 120if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMinMaxX<float>>(min, max, x, destination)) 152if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination)) 179if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMinMaxX<float>>(min, max, x, destination)) 206if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMaxXMin<float>>(max, x, min, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.ConvertHelpers.cs (5)
126if (typeof(TFrom) == typeof(Half)) 137if (typeof(TTo) == typeof(Half)) 390public static float Invoke(short x) => (float)Unsafe.BitCast<short, Half>(x); 571public static ushort Invoke(float x) => Unsafe.BitCast<Half, ushort>((Half)x);
System\Numerics\Tensors\netcore\TensorPrimitives.CopySign.cs (2)
26if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, CopySignOperator<float>>(x, sign, destination)) 48if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, CopySignOperator<float>>(x, sign, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Cos.cs (1)
31if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, CosOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Cosh.cs (1)
35if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, CoshOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.CosineSimilarity.cs (17)
34if (typeof(T) == typeof(Half)) 37return (T)(object)CosineSimilarityHalfCore(Rename<T, Half>(x), Rename<T, Half>(y)); 183/// <summary>Provides the same implementation as <see cref="CosineSimilarityCore"/>, but specifically for <see cref="Half"/>.</summary> 184private static Half CosineSimilarityHalfCore(ReadOnlySpan<Half> x, ReadOnlySpan<Half> y) 203ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x)); 204ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y)); 240return (Half)Finalize(dotProductVector, xSumOfSquaresVector, ySumOfSquaresVector); 245ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x)); 246ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y)); 282return (Half)Finalize(dotProductVector, xSumOfSquaresVector, ySumOfSquaresVector); 287ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x)); 288ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y)); 324return (Half)Finalize(dotProductVector, xSumOfSquaresVector, ySumOfSquaresVector); 335return (Half)Finalize(dotProduct, xSumOfSquares, ySumOfSquares);
System\Numerics\Tensors\netcore\TensorPrimitives.CosPi.cs (1)
31if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, CosPiOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Decrement.cs (1)
23if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, DecrementOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.DegreesToRadians.cs (1)
24if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, DegreesToRadiansOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Divide.cs (3)
29if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, DivideOperator<float>>(x, y, destination)) 55if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, DivideOperator<float>>(x, y, destination)) 81if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, DivideOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Exp.cs (1)
32if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, ExpOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Exp10.cs (1)
27if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Exp10Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Exp10M1.cs (1)
27if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Exp10M1Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Exp2.cs (1)
27if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Exp2Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Exp2M1.cs (1)
27if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Exp2M1Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.ExpM1.cs (1)
27if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, ExpM1Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Floor.cs (1)
24if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, FloorOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.FusedMultiplyAdd.cs (3)
40if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, FusedMultiplyAddOperator<float>>(x, y, addend, destination)) 75if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, FusedMultiplyAddOperator<float>>(x, y, addend, destination)) 109if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, FusedMultiplyAddOperator<float>>(x, y, addend, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Half.cs (48)
27public static void ConvertToHalf(ReadOnlySpan<float> source, Span<Half> destination) => 45public static void ConvertToSingle(ReadOnlySpan<Half> source, Span<float> destination) => 52Debug.Assert(typeof(T) == typeof(Half)); 54if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 69Debug.Assert(typeof(T) == typeof(Half)); 86Debug.Assert(typeof(T) == typeof(Half)); 88if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 104Debug.Assert(typeof(T) == typeof(Half)); 106if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 110BitConverter.HalfToInt16Bits((Half)(object)y!), 122Debug.Assert(typeof(T) == typeof(Half)); 124if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(y))) 127BitConverter.HalfToInt16Bits((Half)(object)x!), 140Debug.Assert(typeof(T) == typeof(Half)); 158Debug.Assert(typeof(T) == typeof(Half)); 164BitConverter.HalfToInt16Bits((Half)(object)y!), 176Debug.Assert(typeof(T) == typeof(Half)); 178if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 194Debug.Assert(typeof(T) == typeof(Half)); 196if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 200BitConverter.HalfToInt16Bits((Half)(object)y!), 212if (typeof(T) == typeof(Half) && IsVectorizable(Rename<T, Half>(x))) 228Debug.Assert(typeof(T) == typeof(Half)); 230if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 247Debug.Assert(typeof(T) == typeof(Half)); 249if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 253BitConverter.HalfToInt16Bits((Half)(object)y!), 266Debug.Assert(typeof(T) == typeof(Half)); 268if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 273BitConverter.HalfToInt16Bits((Half)(object)z!), 285Debug.Assert(typeof(T) == typeof(Half)); 287if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x))) 291BitConverter.HalfToInt16Bits((Half)(object)y!), 292BitConverter.HalfToInt16Bits((Half)(object)z!), 305private static bool IsVectorizable(ReadOnlySpan<Half> source) => 309/// <summary><see cref="IUnaryOperator{T, T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary> 317(Half)TUnary.Invoke((float)BitConverter.Int16BitsToHalf(x))); 344/// <summary><see cref="IBinaryOperator{T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary> 351BitConverter.HalfToInt16Bits((Half)TBinary.Invoke( 383/// <summary><see cref="IAggregationOperator{T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary> 390BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke( 424return BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke( 432return BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke( 440return BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke( 445public static short IdentityValue => BitConverter.HalfToInt16Bits((Half)TAggregate.IdentityValue); 448/// <summary><see cref="ITernaryOperator{T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary> 455BitConverter.HalfToInt16Bits((Half)TTernary.Invoke(
System\Numerics\Tensors\netcore\TensorPrimitives.Hypot.cs (1)
27if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, HypotOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Increment.cs (1)
23if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, IncrementOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Lerp.cs (3)
32if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, LerpOperator<float>>(x, y, amount, destination)) 60if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, LerpOperator<float>>(x, y, amount, destination)) 88if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, LerpOperator<float>>(x, y, amount, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Log.cs (3)
34if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, LogOperator<float>>(x, destination)) 62if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, LogBaseOperator<float>>(x, y, destination)) 88if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, LogBaseOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Log10.cs (1)
33if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Log10Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Log10P1.cs (1)
33if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Log10P1Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Log2.cs (1)
34if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Log2Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Log2P1.cs (1)
33if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, Log2P1Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.LogP1.cs (1)
33if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, LogP1Operator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Max.cs (3)
29if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MaxOperator<float>>(x, out T result)) 61if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxOperator<float>>(x, y, destination)) 91if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MaxMagnitude.cs (3)
29if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MaxMagnitudeOperator<float>>(x, out T result)) 55if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxMagnitudeOperator<float>>(x, y, destination)) 79if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxMagnitudeOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MaxMagnitudeNumber.cs (3)
30if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MaxMagnitudeNumberOperator<float>>(x, out T result)) 63if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxMagnitudeNumberOperator<float>>(x, y, destination)) 94if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxMagnitudeNumberOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MaxNumber.cs (3)
27if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MaxNumberOperator<float>>(x, out T result)) 59if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxNumberOperator<float>>(x, y, destination)) 89if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MaxNumberOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Min.cs (3)
28if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MinOperator<float>>(x, out T result)) 60if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinOperator<float>>(x, y, destination)) 90if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MinMagnitude.cs (3)
29if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MinMagnitudeOperator<float>>(x, out T result)) 60if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinMagnitudeOperator<float>>(x, y, destination)) 89if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinMagnitudeOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MinMagnitudeNumber.cs (3)
30if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MinMagnitudeNumberOperator<float>>(x, out T result)) 63if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinMagnitudeNumberOperator<float>>(x, y, destination)) 94if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinMagnitudeNumberOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MinNumber.cs (3)
27if (typeof(T) == typeof(Half) && TryMinMaxHalfAsInt16<T, MinNumberOperator<float>>(x, out T result)) 59if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinNumberOperator<float>>(x, y, destination)) 89if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MinNumberOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Multiply.cs (2)
29if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MultiplyOperator<float>>(x, y, destination)) 55if (typeof(T) == typeof(Half) && TryAggregateInvokeHalfAsInt16<T, MultiplyOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MultiplyAdd.cs (3)
31if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddOperator<float>>(x, y, addend, destination)) 60if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddOperator<float>>(x, y, addend, destination)) 88if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddOperator<float>>(x, y, addend, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MultiplyAddEstimate.cs (3)
38if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddEstimateOperator<float>>(x, y, addend, destination)) 71if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddEstimateOperator<float>>(x, y, addend, destination)) 103if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddEstimateOperator<float>>(x, y, addend, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Negate.cs (1)
26if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, NegateOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.OnesComplement.cs (1)
23if (typeof(T) == typeof(Half) && TryUnaryBitwiseInvokeHalfAsInt16<T, OnesComplementOperator<short>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Reciprocal.cs (4)
26if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, ReciprocalOperator<float>>(x, destination)) 48if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, ReciprocalEstimateOperator<float>>(x, destination)) 70if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, ReciprocalSqrtOperator<float>>(x, destination)) 92if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, ReciprocalSqrtEstimateOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Remainder.cs (3)
29if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, RemainderOperator<float>>(x, y, destination)) 55if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, RemainderOperator<float>>(x, y, destination)) 81if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, RemainderOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Round.cs (2)
25if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, RoundToEvenOperator<float>>(x, destination)) 54if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, RoundAwayFromZeroOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Sigmoid.cs (1)
33if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, SigmoidOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Sin.cs (1)
31if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, SinOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Sinh.cs (1)
35if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, SinhOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.SinPi.cs (1)
31if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, SinPiOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Sqrt.cs (1)
23if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, SqrtOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Subtract.cs (3)
29if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, SubtractOperator<float>>(x, y, destination)) 54if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, SubtractOperator<float>>(x, y, destination)) 79if (typeof(T) == typeof(Half) && TryBinaryInvokeHalfAsInt16<T, SubtractOperator<float>>(x, y, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Tan.cs (1)
31if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, TanOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Tanh.cs (1)
35if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, TanhOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.TanPi.cs (1)
30if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, TanPiOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Truncate.cs (1)
26if (typeof(T) == typeof(Half) && TryUnaryInvokeHalfAsInt16<T, TruncateOperator<float>>(x, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Xor.cs (2)
26if (typeof(T) == typeof(Half) && TryBinaryBitwiseInvokeHalfAsInt16<T, XorOperator<short>>(x, y, destination)) 48if (typeof(T) == typeof(Half) && TryBinaryBitwiseInvokeHalfAsInt16<T, XorOperator<short>>(x, y, destination))
System\Numerics\Tensors\TensorPrimitives.Helpers.cs (1)
87typeof(T) == typeof(Half) ||
System.Private.CoreLib (759)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (12)
316public static unsafe byte[] GetBytes(Half value) 318byte[] bytes = new byte[sizeof(Half)]; 330public static unsafe bool TryWriteBytes(Span<byte> destination, Half value) 332if (destination.Length < sizeof(Half)) 705public static Half ToHalf(byte[] value, int startIndex) => Int16BitsToHalf(ToInt16(value, startIndex)); 714public static unsafe Half ToHalf(ReadOnlySpan<byte> value) 716if (value.Length < sizeof(Half)) 718return Unsafe.ReadUnaligned<Half>(ref MemoryMarshal.GetReference(value)); 941public static short HalfToInt16Bits(Half value) => (short)value._value; 949public static Half Int16BitsToHalf(short value) => new Half((ushort)(value)); 998public static ushort HalfToUInt16Bits(Half value) => value._value; 1007public 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)
1768else if (typeof(TOther) == typeof(Half)) 1770Half actualResult = (Half)value; 1842else if (typeof(TOther) == typeof(Half)) 1844Half actualResult = (Half)value; 1916else if (typeof(TOther) == typeof(Half)) 1918Half 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)
1658else if (typeof(TOther) == typeof(Half)) 1660Half actualResult = checked((Half)value); 1746else if (typeof(TOther) == typeof(Half)) 1748Half actualResult = (Half)value;
src\libraries\System.Private.CoreLib\src\System\Double.cs (3)
1244if (typeof(TOther) == typeof(Half)) 1246Half 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) 1187public static Half operator +(Half left, Half right) => (Half)((float)left + (float)right); 1194static Half IAdditiveIdentity<Half, Half>.AdditiveIdentity => new Half(PositiveZeroBits); 1201static Half IBinaryNumber<Half>.AllBitsSet => BitConverter.UInt16BitsToHalf(0xFFFF); 1204public static bool IsPow2(Half value) 1233public static Half Log2(Half value) => (Half)MathF.Log2((float)value); 1240static Half IBitwiseOperators<Half, Half, Half>.operator &(Half left, Half right) 1246static Half IBitwiseOperators<Half, Half, Half>.operator |(Half left, Half right) 1252static Half IBitwiseOperators<Half, Half, Half>.operator ^(Half left, Half right) 1258static Half IBitwiseOperators<Half, Half, Half>.operator ~(Half value) 1268public static Half operator --(Half value) 1272return (Half)tmp; 1280public static Half operator /(Half left, Half right) => (Half)((float)left / (float)right); 1287public static Half Exp(Half x) => (Half)MathF.Exp((float)x); 1290public static Half ExpM1(Half x) => (Half)float.ExpM1((float)x); 1293public static Half Exp2(Half x) => (Half)float.Exp2((float)x); 1296public static Half Exp2M1(Half x) => (Half)float.Exp2M1((float)x); 1299public static Half Exp10(Half x) => (Half)float.Exp10((float)x); 1302public static Half Exp10M1(Half x) => (Half)float.Exp10M1((float)x); 1309public static Half Ceiling(Half x) => (Half)MathF.Ceiling((float)x); 1312public static TInteger ConvertToInteger<TInteger>(Half value) 1316public static TInteger ConvertToIntegerNative<TInteger>(Half value) 1320public static Half Floor(Half x) => (Half)MathF.Floor((float)x); 1323public static Half Round(Half x) => (Half)MathF.Round((float)x); 1326public static Half Round(Half x, int digits) => (Half)MathF.Round((float)x, digits); 1329public static Half Round(Half x, MidpointRounding mode) => (Half)MathF.Round((float)x, mode); 1332public static Half Round(Half x, int digits, MidpointRounding mode) => (Half)MathF.Round((float)x, digits, mode); 1335public static Half Truncate(Half x) => (Half)MathF.Truncate((float)x); 1338int IFloatingPoint<Half>.GetExponentByteCount() => sizeof(sbyte); 1341int IFloatingPoint<Half>.GetExponentShortestBitLength() 1356int IFloatingPoint<Half>.GetSignificandByteCount() => sizeof(ushort); 1359int IFloatingPoint<Half>.GetSignificandBitLength() => SignificandLength; 1362bool IFloatingPoint<Half>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten) 1376bool IFloatingPoint<Half>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten) 1390bool IFloatingPoint<Half>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten) 1403bool IFloatingPoint<Half>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten) 1420public static Half E => new Half(EBits); 1423public static Half Pi => new Half(PiBits); 1426public static Half Tau => new Half(TauBits); 1433public static Half NegativeZero => new Half(NegativeZeroBits); 1436public static Half Atan2(Half y, Half x) => (Half)MathF.Atan2((float)y, (float)x); 1439public static Half Atan2Pi(Half y, Half x) => (Half)float.Atan2Pi((float)y, (float)x); 1442public static Half BitDecrement(Half x) 1475public static Half BitIncrement(Half x) 1508public static Half FusedMultiplyAdd(Half left, Half right, Half addend) => (Half)MathF.FusedMultiplyAdd((float)left, (float)right, (float)addend); 1511public static Half Ieee754Remainder(Half left, Half right) => (Half)MathF.IEEERemainder((float)left, (float)right); 1514public static int ILogB(Half x) 1542public static Half Lerp(Half value1, Half value2, Half amount) => (Half)float.Lerp((float)value1, (float)value2, (float)amount); 1545public static Half ReciprocalEstimate(Half x) => (Half)MathF.ReciprocalEstimate((float)x); 1548public static Half ReciprocalSqrtEstimate(Half x) => (Half)MathF.ReciprocalSqrtEstimate((float)x); 1551public static Half ScaleB(Half x, int n) => (Half)MathF.ScaleB((float)x, n); 1561public static Half Acosh(Half x) => (Half)MathF.Acosh((float)x); 1564public static Half Asinh(Half x) => (Half)MathF.Asinh((float)x); 1567public static Half Atanh(Half x) => (Half)MathF.Atanh((float)x); 1570public static Half Cosh(Half x) => (Half)MathF.Cosh((float)x); 1573public static Half Sinh(Half x) => (Half)MathF.Sinh((float)x); 1576public static Half Tanh(Half x) => (Half)MathF.Tanh((float)x); 1583public static Half operator ++(Half value) 1587return (Half)tmp; 1595public static Half Log(Half x) => (Half)MathF.Log((float)x); 1598public static Half Log(Half x, Half newBase) => (Half)MathF.Log((float)x, (float)newBase); 1601public static Half Log10(Half x) => (Half)MathF.Log10((float)x); 1604public static Half LogP1(Half x) => (Half)float.LogP1((float)x); 1607public static Half Log2P1(Half x) => (Half)float.Log2P1((float)x); 1610public static Half Log10P1(Half x) => (Half)float.Log10P1((float)x); 1617public static Half operator %(Half left, Half right) => (Half)((float)left % (float)right); 1624public static Half MultiplicativeIdentity => new Half(PositiveOneBits); 1631public static Half operator *(Half left, Half right) => (Half)((float)left * (float)right); 1638public static Half Clamp(Half value, Half min, Half max) => (Half)float.Clamp((float)value, (float)min, (float)max); 1641public static Half ClampNative(Half value, Half min, Half max) 1651public static Half CopySign(Half value, Half sign) 1664public static Half Max(Half x, Half y) => (Half)float.Max((float)x, (float)y); 1667public static Half MaxNative(Half x, Half y) => (x > y) ? x : y; 1670public static Half MaxNumber(Half x, Half y) 1692public static Half Min(Half x, Half y) => (Half)float.Min((float)x, (float)y); 1695public static Half MinNative(Half x, Half y) => (x < y) ? x : y; 1698public static Half MinNumber(Half x, Half y) 1720public static int Sign(Half value) 1744public static Half One => new Half(PositiveOneBits); 1747static int INumberBase<Half>.Radix => 2; 1750public static Half Zero => new Half(PositiveZeroBits); 1753public static Half Abs(Half value) => new Half((ushort)(value._value & ~SignMask)); 1757public static Half CreateChecked<TOther>(TOther value) 1760Half result; 1762if (typeof(TOther) == typeof(Half)) 1764result = (Half)(object)value; 1776public static Half CreateSaturating<TOther>(TOther value) 1779Half result; 1781if (typeof(TOther) == typeof(Half)) 1783result = (Half)(object)value; 1795public static Half CreateTruncating<TOther>(TOther value) 1798Half result; 1800if (typeof(TOther) == typeof(Half)) 1802result = (Half)(object)value; 1813static bool INumberBase<Half>.IsCanonical(Half value) => true; 1816static bool INumberBase<Half>.IsComplexNumber(Half value) => false; 1819public static bool IsEvenInteger(Half value) => float.IsEvenInteger((float)value); 1822static bool INumberBase<Half>.IsImaginaryNumber(Half value) => false; 1825public static bool IsInteger(Half value) => float.IsInteger((float)value); 1828public static bool IsOddInteger(Half value) => float.IsOddInteger((float)value); 1831public static bool IsPositive(Half value) => (short)(value._value) >= 0; 1834public static bool IsRealNumber(Half value) 1845static bool INumberBase<Half>.IsZero(Half value) => IsZero(value); 1848public static Half MaxMagnitude(Half x, Half y) => (Half)MathF.MaxMagnitude((float)x, (float)y); 1851public static Half MaxMagnitudeNumber(Half x, Half y) 1859Half ax = Abs(x); 1860Half ay = Abs(y); 1876public static Half MinMagnitude(Half x, Half y) => (Half)MathF.MinMagnitude((float)x, (float)y); 1879public static Half MinMagnitudeNumber(Half x, Half y) 1887Half ax = Abs(x); 1888Half ay = Abs(y); 1904public static Half MultiplyAddEstimate(Half left, Half right, Half addend) => (Half)float.MultiplyAddEstimate((float)left, (float)right, (float)addend); 1908static bool INumberBase<Half>.TryConvertFromChecked<TOther>(TOther value, out Half result) 1915static bool INumberBase<Half>.TryConvertFromSaturating<TOther>(TOther value, out Half result) 1922static bool INumberBase<Half>.TryConvertFromTruncating<TOther>(TOther value, out Half result) 1928private static bool TryConvertFrom<TOther>(TOther value, out Half result) 1943result = (Half)actualValue; 1949result = (Half)actualValue; 1955result = (Half)actualValue; 1961result = (Half)actualValue; 1967result = (Half)actualValue; 1973result = (Half)actualValue; 1985result = (Half)actualValue; 1997static bool INumberBase<Half>.TryConvertToChecked<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2065static bool INumberBase<Half>.TryConvertToSaturating<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2072static bool INumberBase<Half>.TryConvertToTruncating<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2078private static bool TryConvertTo<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2172public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out Half result) => TryParse(s, DefaultParseStyle, provider, out result); 2179public static Half Pow(Half x, Half y) => (Half)MathF.Pow((float)x, (float)y); 2186public static Half Cbrt(Half x) => (Half)MathF.Cbrt((float)x); 2189public static Half Hypot(Half x, Half y) => (Half)float.Hypot((float)x, (float)y); 2192public static Half RootN(Half x, int n) => (Half)float.RootN((float)x, n); 2195public static Half Sqrt(Half x) => (Half)MathF.Sqrt((float)x); 2202public static Half NegativeOne => new Half(NegativeOneBits); 2209public static Half Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, DefaultParseStyle, provider); 2212public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out Half result) => TryParse(s, DefaultParseStyle, provider, out result); 2219public static Half operator -(Half left, Half right) => (Half)((float)left - (float)right); 2226public static Half Acos(Half x) => (Half)MathF.Acos((float)x); 2229public static Half AcosPi(Half x) => (Half)float.AcosPi((float)x); 2232public static Half Asin(Half x) => (Half)MathF.Asin((float)x); 2235public static Half AsinPi(Half x) => (Half)float.AsinPi((float)x); 2238public static Half Atan(Half x) => (Half)MathF.Atan((float)x); 2241public static Half AtanPi(Half x) => (Half)float.AtanPi((float)x); 2244public static Half Cos(Half x) => (Half)MathF.Cos((float)x); 2247public static Half CosPi(Half x) => (Half)float.CosPi((float)x); 2250public static Half DegreesToRadians(Half degrees) 2255return (Half)float.DegreesToRadians((float)degrees); 2259public static Half RadiansToDegrees(Half radians) 2264return (Half)float.RadiansToDegrees((float)radians); 2268public static Half Sin(Half x) => (Half)MathF.Sin((float)x); 2271public static (Half Sin, Half Cos) SinCos(Half x) 2274return ((Half)sin, (Half)cos); 2278public static (Half SinPi, Half CosPi) SinCosPi(Half x) 2281return ((Half)sinPi, (Half)cosPi); 2285public static Half SinPi(Half x) => (Half)float.SinPi((float)x); 2288public static Half Tan(Half x) => (Half)MathF.Tan((float)x); 2291public static Half TanPi(Half x) => (Half)float.TanPi((float)x); 2298public static Half operator -(Half value) => (Half)(-(float)value); 2305public static Half operator +(Half value) => value; 2312public static Half Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = NumberStyles.Float | NumberStyles.AllowThousands, IFormatProvider? provider = null) 2315return Number.ParseFloat<byte, Half>(utf8Text, style, NumberFormatInfo.GetInstance(provider)); 2319public static bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out Half result) 2326public static Half Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider); 2329public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Half result) => TryParse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider, out result); 2335static int IBinaryFloatParseAndFormatInfo<Half>.NumberBufferLength => Number.HalfNumberBufferLength; 2337static ulong IBinaryFloatParseAndFormatInfo<Half>.ZeroBits => 0; 2338static ulong IBinaryFloatParseAndFormatInfo<Half>.InfinityBits => PositiveInfinityBits; 2340static ulong IBinaryFloatParseAndFormatInfo<Half>.NormalMantissaMask => (1UL << SignificandLength) - 1; 2341static ulong IBinaryFloatParseAndFormatInfo<Half>.DenormalMantissaMask => TrailingSignificandMask; 2343static int IBinaryFloatParseAndFormatInfo<Half>.MinBinaryExponent => 1 - MaxExponent; 2344static int IBinaryFloatParseAndFormatInfo<Half>.MaxBinaryExponent => MaxExponent; 2346static int IBinaryFloatParseAndFormatInfo<Half>.MinDecimalExponent => -8; 2347static int IBinaryFloatParseAndFormatInfo<Half>.MaxDecimalExponent => 5; 2349static int IBinaryFloatParseAndFormatInfo<Half>.ExponentBias => ExponentBias; 2350static ushort IBinaryFloatParseAndFormatInfo<Half>.ExponentBits => BiasedExponentLength; 2352static int IBinaryFloatParseAndFormatInfo<Half>.OverflowDecimalExponent => (MaxExponent + (2 * SignificandLength)) / 3; 2353static int IBinaryFloatParseAndFormatInfo<Half>.InfinityExponent => MaxBiasedExponent; 2355static ushort IBinaryFloatParseAndFormatInfo<Half>.NormalMantissaBits => SignificandLength; 2356static ushort IBinaryFloatParseAndFormatInfo<Half>.DenormalMantissaBits => TrailingSignificandLength; 2358static int IBinaryFloatParseAndFormatInfo<Half>.MinFastFloatDecimalExponent => -26; 2359static int IBinaryFloatParseAndFormatInfo<Half>.MaxFastFloatDecimalExponent => 4; 2361static int IBinaryFloatParseAndFormatInfo<Half>.MinExponentRoundToEven => -21; 2362static int IBinaryFloatParseAndFormatInfo<Half>.MaxExponentRoundToEven => 5; 2364static int IBinaryFloatParseAndFormatInfo<Half>.MaxExponentFastPath => 4; 2365static ulong IBinaryFloatParseAndFormatInfo<Half>.MaxMantissaFastPath => 2UL << TrailingSignificandLength; 2367static Half IBinaryFloatParseAndFormatInfo<Half>.BitsToFloat(ulong bits) => BitConverter.UInt16BitsToHalf((ushort)(bits)); 2369static ulong IBinaryFloatParseAndFormatInfo<Half>.FloatToBits(Half value) => BitConverter.HalfToUInt16Bits(value); 2371static int IBinaryFloatParseAndFormatInfo<Half>.MaxRoundTripDigits => 5; 2373static int IBinaryFloatParseAndFormatInfo<Half>.MaxPrecisionCustomFormat => 5;
src\libraries\System.Private.CoreLib\src\System\Int128.cs (14)
241/// <summary>Explicitly converts a 128-bit signed integer to a <see cref="Half" /> value.</summary> 243/// <returns><paramref name="value" /> converted to a <see cref="Half" />.</returns> 244public static explicit operator Half(Int128 value) 249return -(Half)(UInt128)(value); 251return (Half)(UInt128)(value); 1519else if (typeof(TOther) == typeof(Half)) 1521Half actualValue = (Half)(object)value; 1591else if (typeof(TOther) == typeof(Half)) 1593Half actualValue = (Half)(object)value; 1663else if (typeof(TOther) == typeof(Half)) 1665Half actualValue = (Half)(object)value;
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 (9)
936else if (typeof(TOther) == typeof(Half)) 938Half actualValue = (Half)(object)value; 1013else if (typeof(TOther) == typeof(Half)) 1015Half actualValue = (Half)(object)value; 1103else if (typeof(TOther) == typeof(Half)) 1105Half actualValue = (Half)(object)value;
src\libraries\System.Private.CoreLib\src\System\Int64.cs (9)
933else if (typeof(TOther) == typeof(Half)) 935Half actualValue = (Half)(object)value; 1010else if (typeof(TOther) == typeof(Half)) 1012Half actualValue = (Half)(object)value; 1098else if (typeof(TOther) == typeof(Half)) 1100Half actualValue = (Half)(object)value;
src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (9)
946else if (typeof(TOther) == typeof(Half)) 948Half actualValue = (Half)(object)value; 1023else if (typeof(TOther) == typeof(Half)) 1025Half actualValue = (Half)(object)value; 1112else if (typeof(TOther) == typeof(Half)) 1114Half actualValue = (Half)(object)value;
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\BFloat16.cs (15)
564/// <summary>Explicitly converts a <see cref="Half" /> value to its nearest representable <see cref="BFloat16"/> value.</summary> 567public static explicit operator BFloat16(Half value) => (BFloat16)(float)value; 814/// <summary>Explicitly converts a <see cref="BFloat16" /> value to its nearest representable <see cref="Half" /> value.</summary> 816/// <returns><paramref name="value" /> converted to its nearest representable <see cref="Half" /> value.</returns> 817public static explicit operator Half(BFloat16 value) => (Half)(float)value; 1586else if (typeof(TOther) == typeof(Half)) 1588Half actualValue = (Half)(object)value; 1702else if (typeof(TOther) == typeof(Half)) 1704Half actualResult = (Half)value; 1832else if (typeof(TOther) == typeof(Half)) 1834Half actualResult = (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)
1269else if (typeof(TOther) == typeof(Half)) 1271Half actualValue = (Half)(object)value;
src\libraries\System.Private.CoreLib\src\System\UInt128.cs (13)
285/// <summary>Explicitly converts a 128-bit unsigned integer to a <see cref="Half" /> value.</summary> 287/// <returns><paramref name="value" /> converted to a <see cref="Half" />.</returns> 288public static explicit operator Half(UInt128 value) => (Half)(double)(value); 1793else if (typeof(TOther) == typeof(Half)) 1795Half actualResult = (Half)value; 1867else if (typeof(TOther) == typeof(Half)) 1869Half actualResult = (Half)value; 1947else if (typeof(TOther) == typeof(Half)) 1949Half actualResult = (Half)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)
976else if (typeof(TOther) == typeof(Half)) 978Half actualResult = (Half)value; 1050else if (typeof(TOther) == typeof(Half)) 1052Half actualResult = (Half)value; 1124else if (typeof(TOther) == typeof(Half)) 1126Half actualResult = (Half)value;
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
262[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Half))]
System.Runtime.Numerics (41)
System\Numerics\BigInteger.cs (26)
1912/// <summary>Explicitly converts a big integer to a <see cref="Half" /> value.</summary> 1914/// <returns><paramref name="value" /> converted to <see cref="Half" /> value.</returns> 1915public static explicit operator Half(BigInteger value) 1917return (Half)(double)value; 2173/// <summary>Explicitly converts a <see cref="Half" /> value to a big integer.</summary> 2176public static explicit operator BigInteger(Half value) 4027else if (typeof(TOther) == typeof(Half)) 4029Half actualValue = (Half)(object)value; 4150else if (typeof(TOther) == typeof(Half)) 4152Half actualValue = (Half)(object)value; 4153result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue; 4273else if (typeof(TOther) == typeof(Half)) 4275Half actualValue = (Half)(object)value; 4276result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue; 4392else if (typeof(TOther) == typeof(Half)) 4394Half actualResult = (Half)value; 4540else if (typeof(TOther) == typeof(Half)) 4542Half actualResult = (Half)value; 4751else if (typeof(TOther) == typeof(Half)) 4753Half actualResult = (Half)value;
System\Numerics\Complex.cs (15)
829/// <summary>Implicitly converts a <see cref="Half" /> value to a double-precision complex number.</summary> 832public static implicit operator Complex(Half value) 1545else if (typeof(TOther) == typeof(Half)) 1547Half actualValue = (Half)(object)value; 1684else if (typeof(TOther) == typeof(Half)) 1686Half actualResult = (value.m_imaginary != 0) ? Half.NaN : (Half)value.m_real; 1883else if (typeof(TOther) == typeof(Half)) 1885Half actualResult = (Half)value.m_real; 2025else if (typeof(TOther) == typeof(Half)) 2027Half 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)
222public static bool TryGetFloatingPointConstant(ReadOnlySpan<byte> span, out Half value) 228value = Half.NaN; 236value = Half.PositiveInfinity; 244value = Half.NegativeInfinity;
System\Text\Json\Serialization\Converters\Value\HalfConverter.cs (25)
12internal sealed class HalfConverter : JsonPrimitiveConverter<Half> 22public override Half Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 32public override void Write(Utf8JsonWriter writer, Half value, JsonSerializerOptions options) 37private static Half ReadCore(ref Utf8JsonReader reader) 39Half result; 62Debug.Assert(!Half.IsNaN(result) && !Half.IsInfinity(result)); 66private static void WriteCore(Utf8JsonWriter writer, Half value) 73internal override Half ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 79internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Half value, JsonSerializerOptions options, bool isWritingExtensionDataProperty) 86internal override Half ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options) 92if (TryGetFloatingPointConstant(ref reader, out Half value)) 101if (!TryGetFloatingPointConstant(ref reader, out Half value)) 113internal override void WriteNumberWithCustomHandling(Utf8JsonWriter writer, Half value, JsonNumberHandling handling) 139private static bool TryGetFloatingPointConstant(ref Utf8JsonReader reader, out Half value) 176private static void WriteFloatingPointConstant(Utf8JsonWriter writer, Half value) 178if (Half.IsNaN(value)) 182else if (Half.IsPositiveInfinity(value)) 186else if (Half.IsNegativeInfinity(value)) 196private static bool TryParse(ReadOnlySpan<byte> buffer, out Half result) 198bool success = Half.TryParse(buffer, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result); 203(!Half.IsNaN(result) || buffer.SequenceEqual(JsonConstants.NaNValue)) && 204(!Half.IsPositiveInfinity(result) || buffer.SequenceEqual(JsonConstants.PositiveInfinityValue)) && 205(!Half.IsNegativeInfinity(result) || buffer.SequenceEqual(JsonConstants.NegativeInfinityValue)); 210Half 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) ||