29 instantiations of Half
System.Private.CoreLib (29)
src\runtime\src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (2)
1002public static Half Int16BitsToHalf(short value) => new Half((ushort)(value)); 1072public static Half UInt16BitsToHalf(ushort value) => new Half(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Half.cs (27)
92public static Half Epsilon { [Intrinsic] get => new Half(EpsilonBits); } // 5.9604645E-08 94public static Half PositiveInfinity { [Intrinsic] get => new Half(PositiveInfinityBits); } // 1.0 / 0.0; 96public static Half NegativeInfinity { [Intrinsic] get => new Half(NegativeInfinityBits); } // -1.0 / 0.0 98public static Half NaN { [Intrinsic] get => new Half(NegativeQNaNBits); } // 0.0 / 0.0 101public static Half MinValue { [Intrinsic] get => new Half(MinValueBits); } // -65504 104public static Half MaxValue { [Intrinsic] get => new Half(MaxValueBits); } // 65504 614return new Half(sign, 0, 0); 616return new Half(RoundPackToHalf(sign, (short)(exp - 0x3F1), (ushort)(sigHalf | 0x4000))); 1133return IsNaN(value) ? value : new Half((ushort)(value._value ^ SignMask)); 1183return new Half(sign, (ushort)exp, sig)._value; 1228static Half IAdditiveIdentity<Half, Half>.AdditiveIdentity => new Half(PositiveZeroBits); 1276return new Half((ushort)(left._value & right._value)); 1282return new Half((ushort)(left._value | right._value)); 1288return new Half((ushort)(left._value ^ right._value)); 1294return new Half((ushort)(~value._value)); 1460public static Half E => new Half(EBits); 1463public static Half Pi => new Half(PiBits); 1466public static Half Tau => new Half(TauBits); 1473public static Half NegativeZero => new Half(NegativeZeroBits); 1511return new Half((ushort)bits); 1544return new Half((ushort)bits); 1677public static Half MultiplicativeIdentity => new Half(PositiveOneBits); 1714return new Half((ushort)((xbits & ~SignMask) | (ybits & SignMask))); 1798public static Half One { [Intrinsic] get => new Half(PositiveOneBits); } 1804public static Half Zero { [Intrinsic] get => new Half(PositiveZeroBits); } 1807public static Half Abs(Half value) => new Half((ushort)(value._value & ~SignMask)); 2278public static Half NegativeOne => new Half(NegativeOneBits);
1184 references to Half
GenerateDocumentationAndConfigFiles (17)
src\roslyn\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.AspNetCore.Components.Endpoints (7)
FormMapping\Converters\NullableConverter.cs (1)
73type == typeof(Half);
FormMapping\WellKnownConverters.cs (6)
36{ typeof(Half), new ParsableConverter<Half>() }, 68converters.Add(typeof(Half?), new NullableConverter<Half>((FormDataConverter<Half>)converters[typeof(Half)]));
Microsoft.AspNetCore.Http.Extensions (11)
src\aspnetcore\src\Components\Endpoints\src\FormMapping\Converters\NullableConverter.cs (1)
73type == typeof(Half);
src\aspnetcore\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\aspnetcore\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\aspnetcore\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)
42typeof(Half),
src\aspnetcore\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.Build (17)
src\msbuild\artifacts\.packages\microsoft.codeanalysis.collections\5.0.0-1.25277.114\contentFiles\cs\net9.0\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 (17)
src\roslyn\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\roslyn\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.Integration.Tests (7)
EmbeddingGeneratorIntegrationTests.cs (2)
185using IEmbeddingGenerator<string, Embedding<Half>> generator = 192var 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 (12)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.GetJsonTypeInfo.g.cs (1)
324if (type == typeof(global::System.Half))
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\TestTypesContext.Half.g.cs (8)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Half>? _Half; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Half> Half 24get => _Half ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Half>)Options.GetTypeInfo(typeof(global::System.Half)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Half> Create_Half(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Half>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Half> jsonTypeInfo)) 31jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateValueInfo<global::System.Half>(options, global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.HalfConverter);
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)
65typeof(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 (186)
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.BitDecrement.cs (2)
25if (typeof(T) == typeof(Half) && TryUnaryBitwiseInvokeHalfAsInt16<T, HalfBitDecrementOperator>(x, destination)) 205public static short Invoke(short x) => BitConverter.HalfToInt16Bits(Half.BitDecrement(BitConverter.Int16BitsToHalf(x)));
System\Numerics\Tensors\netcore\TensorPrimitives.BitIncrement.cs (2)
25if (typeof(T) == typeof(Half) && TryUnaryBitwiseInvokeHalfAsInt16<T, HalfBitIncrementOperator>(x, destination)) 205public static short Invoke(short x) => BitConverter.HalfToInt16Bits(Half.BitIncrement(BitConverter.Int16BitsToHalf(x)));
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 (10)
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)) 147if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination)) 174if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMinMaxX<float>>(min, max, x, destination)) 201if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMaxXMin<float>>(max, x, min, destination)) 220public static T Invoke(T x, T min, T max) => Vector128<T>.IsSupported || typeof(T) == typeof(Half) ? T.Min(T.Max(x, min), max) : T.Clamp(x, min, max); 233public static T Invoke(T min, T max, T x) => Vector128<T>.IsSupported || typeof(T) == typeof(Half) ? T.Min(T.Max(x, min), max) : T.Clamp(x, min, max); 246public static T Invoke(T max, T x, T min) => Vector128<T>.IsSupported || typeof(T) == typeof(Half) ? T.Min(T.Max(x, min), max) : T.Clamp(x, min, max);
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 (803)
src\runtime\src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (12)
344public static unsafe byte[] GetBytes(Half value) 346byte[] bytes = new byte[sizeof(Half)]; 358public static unsafe bool TryWriteBytes(Span<byte> destination, Half value) 360if (destination.Length < sizeof(Half)) 758public static Half ToHalf(byte[] value, int startIndex) => Int16BitsToHalf(ToInt16(value, startIndex)); 767public static unsafe Half ToHalf(ReadOnlySpan<byte> value) 769if (value.Length < sizeof(Half)) 771return Unsafe.ReadUnaligned<Half>(ref MemoryMarshal.GetReference(value)); 994public static short HalfToInt16Bits(Half value) => (short)value._value; 1002public static Half Int16BitsToHalf(short value) => new Half((ushort)(value)); 1063public static ushort HalfToUInt16Bits(Half value) => value._value; 1072public static Half UInt16BitsToHalf(ushort value) => new Half(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReadBigEndian.cs (7)
30/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as big endian. 36/// <paramref name="source"/> is too small to contain a <see cref="Half" />. 39public static Half ReadHalfBigEndian(ReadOnlySpan<byte> source) 43MemoryMarshal.Read<Half>(source); 278/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as big endian. 283/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 287public static bool TryReadHalfBigEndian(ReadOnlySpan<byte> source, out Half value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReadLittleEndian.cs (8)
30/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as little endian. 36/// <paramref name="source"/> is too small to contain a <see cref="Half" />. 39public static Half ReadHalfLittleEndian(ReadOnlySpan<byte> source) 43MemoryMarshal.Read<Half>(source); 53/// <paramref name="source"/> is too small to contain a <see cref="Half" />. 278/// Reads a <see cref="Half" /> from the beginning of a read-only span of bytes, as little endian. 283/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 287public static bool TryReadHalfLittleEndian(ReadOnlySpan<byte> source, out Half value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.WriteBigEndian.cs (6)
36/// Writes a <see cref="Half" /> into a span of bytes, as big endian. 42/// <paramref name="destination" /> is too small to contain a <see cref="Half" />. 45public static void WriteHalfBigEndian(Span<byte> destination, Half value) 361/// Writes a <see cref="Half" /> into a span of bytes, as big endian. 366/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 370public static bool TryWriteHalfBigEndian(Span<byte> destination, Half value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.WriteLittleEndian.cs (6)
36/// Writes a <see cref="Half" /> into a span of bytes, as little endian. 42/// <paramref name="destination" /> is too small to contain a <see cref="Half" />. 45public static void WriteHalfLittleEndian(Span<byte> destination, Half value) 361/// Writes a <see cref="Half" /> into a span of bytes, as little endian. 366/// <see langword="true" /> if the span is large enough to contain a <see cref="Half" />; otherwise, <see langword="false" />. 370public static bool TryWriteHalfLittleEndian(Span<byte> destination, Half value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Byte.cs (6)
898else if (typeof(TOther) == typeof(Half)) 900Half actualResult = value; 972else if (typeof(TOther) == typeof(Half)) 974Half actualResult = value; 1046else if (typeof(TOther) == typeof(Half)) 1048Half actualResult = value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Char.cs (9)
1770else if (typeof(TOther) == typeof(Half)) 1772Half actualResult = (Half)value; 1844else if (typeof(TOther) == typeof(Half)) 1846Half actualResult = (Half)value; 1918else if (typeof(TOther) == typeof(Half)) 1920Half actualResult = (Half)value;
src\runtime\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\runtime\src\libraries\System.Private.CoreLib\src\System\Decimal.cs (6)
1628else if (typeof(TOther) == typeof(Half)) 1630Half actualResult = checked((Half)value); 1716else if (typeof(TOther) == typeof(Half)) 1718Half actualResult = (Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Double.cs (3)
1260if (typeof(TOther) == typeof(Half)) 1262Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Half.cs (536)
26IComparable<Half>, 27IEquatable<Half>, 28IBinaryFloatingPointIeee754<Half>, 29IMinMaxValue<Half>, 31IBinaryFloatParseAndFormatInfo<Half> 92public static Half Epsilon { [Intrinsic] get => new Half(EpsilonBits); } // 5.9604645E-08 94public static Half PositiveInfinity { [Intrinsic] get => new Half(PositiveInfinityBits); } // 1.0 / 0.0; 96public static Half NegativeInfinity { [Intrinsic] get => new Half(NegativeInfinityBits); } // -1.0 / 0.0 98public static Half NaN { [Intrinsic] get => new Half(NegativeQNaNBits); } // 0.0 / 0.0 101public static Half MinValue { [Intrinsic] get => new Half(MinValueBits); } // -65504 104public static Half MaxValue { [Intrinsic] get => new Half(MaxValueBits); } // 65504 161public static bool operator <(Half left, Half right) 190public static bool operator >(Half left, Half right) 197public static bool operator <=(Half left, Half right) 226public static bool operator >=(Half left, Half right) 233public static bool operator ==(Half left, Half right) 247public static bool operator !=(Half left, Half right) 255public static bool IsFinite(Half value) 263public static bool IsInfinity(Half value) 271public static bool IsNaN(Half value) 278internal static bool IsNaNOrZero(Half value) 286public static bool IsNegative(Half value) 293public static bool IsNegativeInfinity(Half value) 301public static bool IsNormal(Half value) 309public static bool IsPositiveInfinity(Half value) 317public static bool IsSubnormal(Half value) 324internal static bool IsZero(Half value) 331/// Parses a <see cref="Half"/> from a <see cref="string"/> in the default parse style. 334/// <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> 335public static Half Parse(string s) => Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null); 338/// Parses a <see cref="Half"/> from a <see cref="string"/> in the given <see cref="NumberStyles"/>. 342/// <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> 343public static Half Parse(string s, NumberStyles style) => Parse(s, style, provider: null); 346/// Parses a <see cref="Half"/> from a <see cref="string"/> and <see cref="IFormatProvider"/>. 350/// <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> 351public static Half Parse(string s, IFormatProvider? provider) => Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider); 354/// Parses a <see cref="Half"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>. 359/// <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> 360public static Half Parse(string s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null) 370/// Parses a <see cref="Half"/> from a <see cref="ReadOnlySpan{Char}"/> and <see cref="IFormatProvider"/>. 375/// <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> 376public static Half Parse(ReadOnlySpan<char> s, NumberStyles style = DefaultParseStyle, IFormatProvider? provider = null) 379return Number.ParseFloat<char, Half>(s, style, NumberFormatInfo.GetInstance(provider)); 383/// Tries to parse a <see cref="Half"/> from a <see cref="string"/> in the default parse style. 386/// <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> 388public static bool TryParse([NotNullWhen(true)] string? s, out Half result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result); 391/// Tries to parse a <see cref="Half"/> from a <see cref="ReadOnlySpan{Char}"/> in the default parse style. 394/// <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> 396public static bool TryParse(ReadOnlySpan<char> s, out Half result) => TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result); 402public static bool TryParse(ReadOnlySpan<byte> utf8Text, out Half result) => TryParse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider: null, out result); 405/// Tries to parse a <see cref="Half"/> from a <see cref="string"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>. 410/// <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> 412public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out Half result) 419/// Tries to parse a <see cref="Half"/> from a <see cref="ReadOnlySpan{Char}"/> with the given <see cref="NumberStyles"/> and <see cref="IFormatProvider"/>. 424/// <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> 426public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out Half result) 432private static bool AreZero(Half left, Half right) 444/// <exception cref="ArgumentException">Thrown when <paramref name="obj"/> is not of type <see cref="Half"/>.</exception> 447if (obj is not Half other) 458public int CompareTo(Half other) 492return (obj is Half other) && Equals(other); 498public bool Equals(Half other) 579public static explicit operator Half(char value) => (Half)(float)value; 587public static explicit operator Half(decimal value) => (Half)(double)value; 593public static explicit operator Half(double value) 622public static explicit operator Half(short value) => (Half)(float)value; 628public static explicit operator Half(int value) => (Half)(float)value; 634public static explicit operator Half(long value) => (Half)(float)value; 639public static explicit operator Half(nint value) => (Half)(float)value; 645public static explicit operator Half(float value) 812public static explicit operator Half(ushort value) => (Half)(float)value; 819public static explicit operator Half(uint value) => (Half)(float)value; 826public static explicit operator Half(ulong value) => (Half)(float)value; 832public static explicit operator Half(nuint value) => (Half)(float)value; 841public static explicit operator byte(Half value) => (byte)(float)value; 847public static explicit operator checked byte(Half value) => checked((byte)(float)value); 852public static explicit operator char(Half value) => (char)(float)value; 858public static explicit operator checked char(Half value) => checked((char)(float)value); 863public static explicit operator decimal(Half value) => (decimal)(float)value; 868public static explicit operator short(Half value) => (short)(float)value; 874public static explicit operator checked short(Half value) => checked((short)(float)value); 880public static explicit operator int(Half value) => (int)(float)value; 886public static explicit operator checked int(Half value) => checked((int)(float)value); 892public static explicit operator long(Half value) => (long)(float)value; 898public static explicit operator checked long(Half value) => checked((long)(float)value); 903public static explicit operator Int128(Half value) => (Int128)(double)(value); 909public static explicit operator checked Int128(Half value) => checked((Int128)(double)(value)); 914public static explicit operator nint(Half value) => (nint)(float)value; 920public static explicit operator checked nint(Half value) => checked((nint)(float)value); 926public static explicit operator sbyte(Half value) => (sbyte)(float)value; 933public static explicit operator checked sbyte(Half value) => checked((sbyte)(float)value); 939public static explicit operator ushort(Half value) => (ushort)(float)value; 946public static explicit operator checked ushort(Half value) => checked((ushort)(float)value); 953public static explicit operator uint(Half value) => (uint)(float)value; 960public static explicit operator checked uint(Half value) => checked((uint)(float)value); 967public static explicit operator ulong(Half value) => (ulong)(float)value; 974public static explicit operator checked ulong(Half value) => checked((ulong)(float)value); 980public static explicit operator UInt128(Half value) => (UInt128)(double)(value); 987public static explicit operator checked UInt128(Half value) => checked((UInt128)(double)(value)); 993public static explicit operator nuint(Half value) => (nuint)(float)value; 1000public static explicit operator checked nuint(Half value) => checked((nuint)(float)value); 1009public static implicit operator Half(byte value) => (Half)(float)value; 1015public static implicit operator Half(sbyte value) => (Half)(float)value; 1025public static explicit operator double(Half value) 1057public static explicit operator float(Half value) 1131internal static Half Negate(Half value) 1146private static Half CreateHalfNaN(bool sign, ulong significand) 1221public static Half operator +(Half left, Half right) => (Half)((float)left + (float)right); 1228static Half IAdditiveIdentity<Half, Half>.AdditiveIdentity => new Half(PositiveZeroBits); 1235static Half IBinaryNumber<Half>.AllBitsSet => BitConverter.UInt16BitsToHalf(0xFFFF); 1238public static bool IsPow2(Half value) 1267public static Half Log2(Half value) => (Half)MathF.Log2((float)value); 1274static Half IBitwiseOperators<Half, Half, Half>.operator &(Half left, Half right) 1280static Half IBitwiseOperators<Half, Half, Half>.operator |(Half left, Half right) 1286static Half IBitwiseOperators<Half, Half, Half>.operator ^(Half left, Half right) 1292static Half IBitwiseOperators<Half, Half, Half>.operator ~(Half value) 1303public static Half operator --(Half value) 1307return (Half)tmp; 1316public static Half operator /(Half left, Half right) => (Half)((float)left / (float)right); 1323public static Half Exp(Half x) => (Half)MathF.Exp((float)x); 1326public static Half ExpM1(Half x) => (Half)float.ExpM1((float)x); 1329public static Half Exp2(Half x) => (Half)float.Exp2((float)x); 1332public static Half Exp2M1(Half x) => (Half)float.Exp2M1((float)x); 1335public static Half Exp10(Half x) => (Half)float.Exp10((float)x); 1338public static Half Exp10M1(Half x) => (Half)float.Exp10M1((float)x); 1346public static Half Ceiling(Half x) => (Half)MathF.Ceiling((float)x); 1349public static TInteger ConvertToInteger<TInteger>(Half value) 1353public static TInteger ConvertToIntegerNative<TInteger>(Half value) 1358public static Half Floor(Half x) => (Half)MathF.Floor((float)x); 1362public static Half Round(Half x) => (Half)MathF.Round((float)x); 1365public static Half Round(Half x, int digits) => (Half)MathF.Round((float)x, digits); 1368public static Half Round(Half x, MidpointRounding mode) => (Half)MathF.Round((float)x, mode); 1371public static Half Round(Half x, int digits, MidpointRounding mode) => (Half)MathF.Round((float)x, digits, mode); 1375public static Half Truncate(Half x) => (Half)MathF.Truncate((float)x); 1378int IFloatingPoint<Half>.GetExponentByteCount() => sizeof(sbyte); 1381int IFloatingPoint<Half>.GetExponentShortestBitLength() 1396int IFloatingPoint<Half>.GetSignificandByteCount() => sizeof(ushort); 1399int IFloatingPoint<Half>.GetSignificandBitLength() => SignificandLength; 1402bool IFloatingPoint<Half>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten) 1416bool IFloatingPoint<Half>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten) 1430bool IFloatingPoint<Half>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten) 1443bool IFloatingPoint<Half>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten) 1460public static Half E => new Half(EBits); 1463public static Half Pi => new Half(PiBits); 1466public static Half Tau => new Half(TauBits); 1473public static Half NegativeZero => new Half(NegativeZeroBits); 1476public static Half Atan2(Half y, Half x) => (Half)MathF.Atan2((float)y, (float)x); 1479public static Half Atan2Pi(Half y, Half x) => (Half)float.Atan2Pi((float)y, (float)x); 1482public static Half BitDecrement(Half x) 1515public static Half BitIncrement(Half x) 1549public static Half FusedMultiplyAdd(Half left, Half right, Half addend) 1557return (Half)Math.FusedMultiplyAdd((double)left, (double)right, (double)addend); 1561public static Half Ieee754Remainder(Half left, Half right) => (Half)MathF.IEEERemainder((float)left, (float)right); 1564public static int ILogB(Half x) 1592public static Half Lerp(Half value1, Half value2, Half amount) => (Half)float.Lerp((float)value1, (float)value2, (float)amount); 1596public static Half ReciprocalEstimate(Half x) => (Half)MathF.ReciprocalEstimate((float)x); 1600public static Half ReciprocalSqrtEstimate(Half x) => (Half)MathF.ReciprocalSqrtEstimate((float)x); 1603public static Half ScaleB(Half x, int n) => (Half)MathF.ScaleB((float)x, n); 1613public static Half Acosh(Half x) => (Half)MathF.Acosh((float)x); 1616public static Half Asinh(Half x) => (Half)MathF.Asinh((float)x); 1619public static Half Atanh(Half x) => (Half)MathF.Atanh((float)x); 1622public static Half Cosh(Half x) => (Half)MathF.Cosh((float)x); 1625public static Half Sinh(Half x) => (Half)MathF.Sinh((float)x); 1628public static Half Tanh(Half x) => (Half)MathF.Tanh((float)x); 1636public static Half operator ++(Half value) 1640return (Half)tmp; 1648public static Half Log(Half x) => (Half)MathF.Log((float)x); 1651public static Half Log(Half x, Half newBase) => (Half)MathF.Log((float)x, (float)newBase); 1654public static Half Log10(Half x) => (Half)MathF.Log10((float)x); 1657public static Half LogP1(Half x) => (Half)float.LogP1((float)x); 1660public static Half Log2P1(Half x) => (Half)float.Log2P1((float)x); 1663public static Half Log10P1(Half x) => (Half)float.Log10P1((float)x); 1670public static Half operator %(Half left, Half right) => (Half)((float)left % (float)right); 1677public static Half MultiplicativeIdentity => new Half(PositiveOneBits); 1685public static Half operator *(Half left, Half right) => (Half)((float)left * (float)right); 1692public static Half Clamp(Half value, Half min, Half max) => (Half)float.Clamp((float)value, (float)min, (float)max); 1695public static Half ClampNative(Half value, Half min, Half max) 1705public static Half CopySign(Half value, Half sign) 1718public static Half Max(Half x, Half y) => (Half)float.Max((float)x, (float)y); 1721public static Half MaxNative(Half x, Half y) => (x > y) ? x : y; 1724public static Half MaxNumber(Half x, Half y) 1746public static Half Min(Half x, Half y) => (Half)float.Min((float)x, (float)y); 1749public static Half MinNative(Half x, Half y) => (x < y) ? x : y; 1752public static Half MinNumber(Half x, Half y) 1774public static int Sign(Half value) 1798public static Half One { [Intrinsic] get => new Half(PositiveOneBits); } 1801static int INumberBase<Half>.Radix => 2; 1804public static Half Zero { [Intrinsic] get => new Half(PositiveZeroBits); } 1807public static Half Abs(Half value) => new Half((ushort)(value._value & ~SignMask)); 1811public static Half CreateChecked<TOther>(TOther value) 1814Half result; 1816if (typeof(TOther) == typeof(Half)) 1818result = (Half)(object)value; 1830public static Half CreateSaturating<TOther>(TOther value) 1833Half result; 1835if (typeof(TOther) == typeof(Half)) 1837result = (Half)(object)value; 1849public static Half CreateTruncating<TOther>(TOther value) 1852Half result; 1854if (typeof(TOther) == typeof(Half)) 1856result = (Half)(object)value; 1867static bool INumberBase<Half>.IsCanonical(Half value) => true; 1870static bool INumberBase<Half>.IsComplexNumber(Half value) => false; 1873public static bool IsEvenInteger(Half value) => float.IsEvenInteger((float)value); 1876static bool INumberBase<Half>.IsImaginaryNumber(Half value) => false; 1879public static bool IsInteger(Half value) => float.IsInteger((float)value); 1882public static bool IsOddInteger(Half value) => float.IsOddInteger((float)value); 1885public static bool IsPositive(Half value) => (short)(value._value) >= 0; 1888public static bool IsRealNumber(Half value) 1899static bool INumberBase<Half>.IsZero(Half value) => IsZero(value); 1902public static Half MaxMagnitude(Half x, Half y) => (Half)MathF.MaxMagnitude((float)x, (float)y); 1905public static Half MaxMagnitudeNumber(Half x, Half y) 1913Half ax = Abs(x); 1914Half ay = Abs(y); 1930public static Half MinMagnitude(Half x, Half y) => (Half)MathF.MinMagnitude((float)x, (float)y); 1933public static Half MinMagnitudeNumber(Half x, Half y) 1941Half ax = Abs(x); 1942Half ay = Abs(y); 1958public static Half MultiplyAddEstimate(Half left, Half right, Half addend) => (Half)float.MultiplyAddEstimate((float)left, (float)right, (float)addend); 1962static bool INumberBase<Half>.TryConvertFromChecked<TOther>(TOther value, out Half result) 1969static bool INumberBase<Half>.TryConvertFromSaturating<TOther>(TOther value, out Half result) 1976static bool INumberBase<Half>.TryConvertFromTruncating<TOther>(TOther value, out Half result) 1982private static bool TryConvertFrom<TOther>(TOther value, out Half result) 1997result = (Half)actualValue; 2003result = (Half)actualValue; 2009result = (Half)actualValue; 2015result = (Half)actualValue; 2021result = (Half)actualValue; 2027result = (Half)actualValue; 2039result = (Half)actualValue; 2051static bool INumberBase<Half>.TryConvertToChecked<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2119static bool INumberBase<Half>.TryConvertToSaturating<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2126static bool INumberBase<Half>.TryConvertToTruncating<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2132private static bool TryConvertTo<TOther>(Half value, [MaybeNullWhen(false)] out TOther result) 2222public static bool TryParsePartial([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out Half result, out int charsConsumed) 2229public static bool TryParsePartial(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out Half result, out int charsConsumed) 2236public static bool TryParsePartial(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out Half result, out int bytesConsumed) 2247public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out Half result) => TryParse(s, DefaultParseStyle, provider, out result); 2254public static Half Pow(Half x, Half y) => (Half)MathF.Pow((float)x, (float)y); 2261public static Half Cbrt(Half x) => (Half)MathF.Cbrt((float)x); 2264public static Half Hypot(Half x, Half y) => (Half)float.Hypot((float)x, (float)y); 2267public static Half RootN(Half x, int n) => (Half)float.RootN((float)x, n); 2271public static Half Sqrt(Half x) => (Half)MathF.Sqrt((float)x); 2278public static Half NegativeOne => new Half(NegativeOneBits); 2285public static Half Parse(ReadOnlySpan<char> s, IFormatProvider? provider) => Parse(s, DefaultParseStyle, provider); 2288public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out Half result) => TryParse(s, DefaultParseStyle, provider, out result); 2296public static Half operator -(Half left, Half right) => (Half)((float)left - (float)right); 2303public static Half Acos(Half x) => (Half)MathF.Acos((float)x); 2306public static Half AcosPi(Half x) => (Half)float.AcosPi((float)x); 2309public static Half Asin(Half x) => (Half)MathF.Asin((float)x); 2312public static Half AsinPi(Half x) => (Half)float.AsinPi((float)x); 2315public static Half Atan(Half x) => (Half)MathF.Atan((float)x); 2318public static Half AtanPi(Half x) => (Half)float.AtanPi((float)x); 2321public static Half Cos(Half x) => (Half)MathF.Cos((float)x); 2324public static Half CosPi(Half x) => (Half)float.CosPi((float)x); 2327public static Half DegreesToRadians(Half degrees) => (Half)float.DegreesToRadians((float)degrees); 2330public static Half RadiansToDegrees(Half radians) => (Half)float.RadiansToDegrees((float)radians); 2333public static Half Sin(Half x) => (Half)MathF.Sin((float)x); 2336public static (Half Sin, Half Cos) SinCos(Half x) 2339return ((Half)sin, (Half)cos); 2343public static (Half SinPi, Half CosPi) SinCosPi(Half x) 2346return ((Half)sinPi, (Half)cosPi); 2350public static Half SinPi(Half x) => (Half)float.SinPi((float)x); 2353public static Half Tan(Half x) => (Half)MathF.Tan((float)x); 2356public static Half TanPi(Half x) => (Half)float.TanPi((float)x); 2363public static Half operator -(Half value) => (Half)(-(float)value); 2370public static Half operator +(Half value) => value; 2377public static Half Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style = NumberStyles.Float | NumberStyles.AllowThousands, IFormatProvider? provider = null) 2380return Number.ParseFloat<byte, Half>(utf8Text, style, NumberFormatInfo.GetInstance(provider)); 2384public static bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFormatProvider? provider, out Half result) 2391public static Half Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider); 2394public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Half result) => TryParse(utf8Text, NumberStyles.Float | NumberStyles.AllowThousands, provider, out result); 2400static int IBinaryFloatParseAndFormatInfo<Half>.NumberBufferLength => Number.HalfNumberBufferLength; 2402static ulong IBinaryFloatParseAndFormatInfo<Half>.ZeroBits => 0; 2403static ulong IBinaryFloatParseAndFormatInfo<Half>.InfinityBits => PositiveInfinityBits; 2405static ulong IBinaryFloatParseAndFormatInfo<Half>.NormalMantissaMask => (1UL << SignificandLength) - 1; 2406static ulong IBinaryFloatParseAndFormatInfo<Half>.DenormalMantissaMask => TrailingSignificandMask; 2408static int IBinaryFloatParseAndFormatInfo<Half>.MinBinaryExponent => 1 - MaxExponent; 2409static int IBinaryFloatParseAndFormatInfo<Half>.MaxBinaryExponent => MaxExponent; 2411static int IBinaryFloatParseAndFormatInfo<Half>.MinDecimalExponent => -8; 2412static int IBinaryFloatParseAndFormatInfo<Half>.MaxDecimalExponent => 5; 2414static int IBinaryFloatParseAndFormatInfo<Half>.ExponentBias => ExponentBias; 2415static ushort IBinaryFloatParseAndFormatInfo<Half>.ExponentBits => BiasedExponentLength; 2417static int IBinaryFloatParseAndFormatInfo<Half>.OverflowDecimalExponent => (MaxExponent + (2 * SignificandLength)) / 3; 2418static int IBinaryFloatParseAndFormatInfo<Half>.InfinityExponent => MaxBiasedExponent; 2420static ushort IBinaryFloatParseAndFormatInfo<Half>.NormalMantissaBits => SignificandLength; 2421static ushort IBinaryFloatParseAndFormatInfo<Half>.DenormalMantissaBits => TrailingSignificandLength; 2423static int IBinaryFloatParseAndFormatInfo<Half>.MinFastFloatDecimalExponent => -26; 2424static int IBinaryFloatParseAndFormatInfo<Half>.MaxFastFloatDecimalExponent => 4; 2426static int IBinaryFloatParseAndFormatInfo<Half>.MinExponentRoundToEven => -21; 2427static int IBinaryFloatParseAndFormatInfo<Half>.MaxExponentRoundToEven => 5; 2429static int IBinaryFloatParseAndFormatInfo<Half>.MaxExponentFastPath => 4; 2430static ulong IBinaryFloatParseAndFormatInfo<Half>.MaxMantissaFastPath => 2UL << TrailingSignificandLength; 2432static Half IBinaryFloatParseAndFormatInfo<Half>.BitsToFloat(ulong bits) => BitConverter.UInt16BitsToHalf((ushort)(bits)); 2434static ulong IBinaryFloatParseAndFormatInfo<Half>.FloatToBits(Half value) => BitConverter.HalfToUInt16Bits(value); 2436static int IBinaryFloatParseAndFormatInfo<Half>.MaxRoundTripDigits => 5; 2438static int IBinaryFloatParseAndFormatInfo<Half>.MaxPrecisionCustomFormat => 5;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int128.cs (14)
235/// <summary>Explicitly converts a 128-bit signed integer to a <see cref="Half" /> value.</summary> 237/// <returns><paramref name="value" /> converted to a <see cref="Half" />.</returns> 238public static explicit operator Half(Int128 value) 243return -(Half)(UInt128)(value); 245return (Half)(UInt128)(value); 1504else if (typeof(TOther) == typeof(Half)) 1506Half actualValue = (Half)(object)value; 1576else if (typeof(TOther) == typeof(Half)) 1578Half actualValue = (Half)(object)value; 1648else if (typeof(TOther) == typeof(Half)) 1650Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int16.cs (9)
876else if (typeof(TOther) == typeof(Half)) 878Half actualValue = (Half)(object)value; 953else if (typeof(TOther) == typeof(Half)) 955Half actualValue = (Half)(object)value; 1040else if (typeof(TOther) == typeof(Half)) 1042Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int32.cs (9)
918else if (typeof(TOther) == typeof(Half)) 920Half actualValue = (Half)(object)value; 995else if (typeof(TOther) == typeof(Half)) 997Half actualValue = (Half)(object)value; 1085else if (typeof(TOther) == typeof(Half)) 1087Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int64.cs (9)
915else if (typeof(TOther) == typeof(Half)) 917Half actualValue = (Half)(object)value; 992else if (typeof(TOther) == typeof(Half)) 994Half actualValue = (Half)(object)value; 1080else if (typeof(TOther) == typeof(Half)) 1082Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (9)
938else if (typeof(TOther) == typeof(Half)) 940Half actualValue = (Half)(object)value; 1015else if (typeof(TOther) == typeof(Half)) 1017Half actualValue = (Half)(object)value; 1104else if (typeof(TOther) == typeof(Half)) 1106Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\BinaryReader.cs (2)
225public virtual unsafe Half ReadHalf() => BinaryPrimitives.ReadHalfLittleEndian(InternalRead(stackalloc byte[sizeof(Half)]));
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\BinaryWriter.cs (1)
334public virtual unsafe void Write(Half value)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.DecimalIeee754.cs (1)
1614/// <see cref="double"/>/<see cref="float"/>/<see cref="Half"/> (and <em>not</em> the round-to-nearest
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\BFloat16.cs (15)
558/// <summary>Explicitly converts a <see cref="Half" /> value to its nearest representable <see cref="BFloat16"/> value.</summary> 561public static explicit operator BFloat16(Half value) => (BFloat16)(float)value; 812/// <summary>Explicitly converts a <see cref="BFloat16" /> value to its nearest representable <see cref="Half" /> value.</summary> 814/// <returns><paramref name="value" /> converted to its nearest representable <see cref="Half" /> value.</returns> 815public 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\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal128.cs (13)
433/// <summary>Explicitly converts a <see cref="System.Half" /> value to its nearest representable <see cref="System.Numerics.Decimal128" /> value.</summary> 436public static explicit operator Decimal128(Half value) => new Decimal128(Number.ConvertFloatToDecimalIeee754<Half, Decimal128, UInt128>(value)); 607/// <summary>Explicitly converts a <see cref="System.Numerics.Decimal128" /> value to its nearest representable <see cref="System.Half" /> value.</summary> 609/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Half" /> value.</returns> 610public static explicit operator Half(Decimal128 value) => Number.ConvertDecimalIeee754ToFloat<Decimal128, UInt128, Half>(new UInt128(value._upper, value._lower)); 1445else if (typeof(TOther) == typeof(Half)) 1447result = (Decimal128)(Half)(object)value; 1568else if (typeof(TOther) == typeof(Half)) 1570result = (TOther)(object)(Half)value; 1687else if (typeof(TOther) == typeof(Half)) 1689result = (TOther)(object)(Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal32.cs (13)
453/// <summary>Explicitly converts a <see cref="System.Half" /> value to its nearest representable <see cref="System.Numerics.Decimal32" /> value.</summary> 456public static explicit operator Decimal32(Half value) => new Decimal32(Number.ConvertFloatToDecimalIeee754<Half, Decimal32, uint>(value)); 642/// <summary>Explicitly converts a <see cref="System.Numerics.Decimal32" /> value to its nearest representable <see cref="System.Half" /> value.</summary> 644/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Half" /> value.</returns> 645public static explicit operator Half(Decimal32 value) => Number.ConvertDecimalIeee754ToFloat<Decimal32, uint, Half>(value._value); 1456else if (typeof(TOther) == typeof(Half)) 1458result = (Decimal32)(Half)(object)value; 1579else if (typeof(TOther) == typeof(Half)) 1581result = (TOther)(object)(Half)value; 1698else if (typeof(TOther) == typeof(Half)) 1700result = (TOther)(object)(Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\Decimal64.cs (13)
445/// <summary>Explicitly converts a <see cref="System.Half" /> value to its nearest representable <see cref="System.Numerics.Decimal64" /> value.</summary> 448public static explicit operator Decimal64(Half value) => new Decimal64(Number.ConvertFloatToDecimalIeee754<Half, Decimal64, ulong>(value)); 629/// <summary>Explicitly converts a <see cref="System.Numerics.Decimal64" /> value to its nearest representable <see cref="System.Half" /> value.</summary> 631/// <returns><paramref name="value" /> converted to its nearest representable <see cref="System.Half" /> value.</returns> 632public static explicit operator Half(Decimal64 value) => Number.ConvertDecimalIeee754ToFloat<Decimal64, ulong, Half>(value._value); 1449else if (typeof(TOther) == typeof(Half)) 1451result = (Decimal64)(Half)(object)value; 1572else if (typeof(TOther) == typeof(Half)) 1574result = (TOther)(object)(Half)value; 1691else if (typeof(TOther) == typeof(Half)) 1693result = (TOther)(object)(Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\TotalOrderIeee754Comparer.cs (3)
62else if (typeof(T) == typeof(Half)) 64return CompareIntegerSemantic(BitConverter.HalfToInt16Bits((Half)(object)x!), BitConverter.HalfToInt16Bits((Half)(object)y!));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NFloat.cs (15)
283/// <summary>Explicitly converts a native-sized floating-point value to its nearest representable <see cref="Half" /> value.</summary> 285/// <returns><paramref name="value" /> converted to its nearest representable <see cref="Half" /> value.</returns> 287public static explicit operator Half(NFloat value) => (Half)(value._value); 466/// <summary>Implicitly converts a <see cref="Half" /> value to its nearest representable native-sized floating-point value.</summary> 470public static implicit operator NFloat(Half value) => (NFloat)(float)value; 1368else if (typeof(TOther) == typeof(Half)) 1370Half actualValue = (Half)(object)value; 1481else if (typeof(TOther) == typeof(Half)) 1483Half actualResult = (Half)value; 1612else if (typeof(TOther) == typeof(Half)) 1614Half actualResult = (Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\SByte.cs (9)
855else if (typeof(TOther) == typeof(Half)) 857Half actualValue = (Half)(object)value; 932else if (typeof(TOther) == typeof(Half)) 934Half actualValue = (Half)(object)value; 1020else if (typeof(TOther) == typeof(Half)) 1022Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Single.cs (3)
1283else if (typeof(TOther) == typeof(Half)) 1285Half actualValue = (Half)(object)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt128.cs (13)
279/// <summary>Explicitly converts a 128-bit unsigned integer to a <see cref="Half" /> value.</summary> 281/// <returns><paramref name="value" /> converted to a <see cref="Half" />.</returns> 282public static explicit operator Half(UInt128 value) => (Half)(double)(value); 1821else if (typeof(TOther) == typeof(Half)) 1823Half actualResult = (Half)value; 1895else if (typeof(TOther) == typeof(Half)) 1897Half actualResult = (Half)value; 1975else if (typeof(TOther) == typeof(Half)) 1977Half actualResult = (Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt16.cs (9)
903else if (typeof(TOther) == typeof(Half)) 905Half actualResult = (Half)value; 977else if (typeof(TOther) == typeof(Half)) 979Half actualResult = (Half)value; 1051else if (typeof(TOther) == typeof(Half)) 1053Half actualResult = (Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt32.cs (9)
968else if (typeof(TOther) == typeof(Half)) 970Half actualResult = (Half)value; 1042else if (typeof(TOther) == typeof(Half)) 1044Half actualResult = (Half)value; 1122else if (typeof(TOther) == typeof(Half)) 1124Half actualResult = (Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt64.cs (9)
975else if (typeof(TOther) == typeof(Half)) 977Half actualResult = (Half)value; 1049else if (typeof(TOther) == typeof(Half)) 1051Half actualResult = (Half)value; 1123else if (typeof(TOther) == typeof(Half)) 1125Half actualResult = (Half)value;
src\runtime\src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (9)
974else if (typeof(TOther) == typeof(Half)) 976Half actualResult = (Half)value; 1048else if (typeof(TOther) == typeof(Half)) 1050Half actualResult = (Half)value; 1122else if (typeof(TOther) == typeof(Half)) 1124Half actualResult = (Half)value;
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
263[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Half))]
System.Runtime.Numerics (30)
System\Numerics\BigInteger.cs (28)
2198/// <summary>Explicitly converts a big integer to a <see cref="Half" /> value.</summary> 2200/// <returns><paramref name="value" /> converted to <see cref="Half" /> value.</returns> 2201public static explicit operator Half(BigInteger value) 2208return (Half)sign; 2214return sign < 0 ? Half.NegativeInfinity : Half.PositiveInfinity; 2489/// <summary>Explicitly converts a <see cref="Half" /> value to a big integer.</summary> 2492public static explicit operator BigInteger(Half value) => new BigInteger((float)value); 4299else if (typeof(TOther) == typeof(Half)) 4301Half actualValue = (Half)(object)value; 4422else if (typeof(TOther) == typeof(Half)) 4424Half actualValue = (Half)(object)value; 4425result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue; 4545else if (typeof(TOther) == typeof(Half)) 4547Half actualValue = (Half)(object)value; 4548result = Half.IsNaN(actualValue) ? Zero : (BigInteger)actualValue; 4664else if (typeof(TOther) == typeof(Half)) 4666Half actualResult = (Half)value; 4812else if (typeof(TOther) == typeof(Half)) 4814Half actualResult = (Half)value; 5023else if (typeof(TOther) == typeof(Half)) 5025Half actualResult = (Half)value;
System\Numerics\Complex.cs (2)
404/// <summary>Implicitly converts a <see cref="Half" /> value to a double-precision complex number.</summary> 407public static implicit operator Complex(Half value)
System.Text.Json (34)
System\Text\Json\Nodes\JsonValueOfT.cs (1)
102if (type == typeof(Half) || type == typeof(UInt128) || type == typeof(Int128))
System\Text\Json\Reader\JsonReaderHelper.cs (4)
299public static bool TryGetFloatingPointConstant(ReadOnlySpan<byte> span, out Half value) 305value = Half.NaN; 313value = Half.PositiveInfinity; 321value = Half.NegativeInfinity;
System\Text\Json\Serialization\Converters\Value\HalfConverter.cs (25)
12internal sealed class HalfConverter : JsonPrimitiveConverter<Half> 24public override Half Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 39public override void Write(Utf8JsonWriter writer, Half value, JsonSerializerOptions options) 50private static unsafe Half ReadCore(ref Utf8JsonReader reader) 52Half result; 75Debug.Assert(!Half.IsNaN(result) && !Half.IsInfinity(result)); 79private static unsafe void WriteCore(Utf8JsonWriter writer, Half value) 86internal override Half ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 92internal override unsafe void WriteAsPropertyNameCore(Utf8JsonWriter writer, Half value, JsonSerializerOptions options, bool isWritingExtensionDataProperty) 99internal override Half ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options) 105if (TryGetFloatingPointConstant(ref reader, out Half value)) 114if (!TryGetFloatingPointConstant(ref reader, out Half value)) 131internal override unsafe void WriteNumberWithCustomHandling(Utf8JsonWriter writer, Half value, JsonNumberHandling handling) 160private static unsafe bool TryGetFloatingPointConstant(ref Utf8JsonReader reader, out Half value) 197private static void WriteFloatingPointConstant(Utf8JsonWriter writer, Half value) 199if (Half.IsNaN(value)) 203else if (Half.IsPositiveInfinity(value)) 207else if (Half.IsNegativeInfinity(value)) 217private static bool TryParse(ReadOnlySpan<byte> buffer, out Half result) 219bool success = Half.TryParse(buffer, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out result); 224(!Half.IsNaN(result) || buffer.SequenceEqual(JsonConstants.NaNValue)) && 225(!Half.IsPositiveInfinity(result) || buffer.SequenceEqual(JsonConstants.PositiveInfinityValue)) && 226(!Half.IsNegativeInfinity(result) || buffer.SequenceEqual(JsonConstants.NegativeInfinityValue)); 231Half 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 (2)
172/// Returns a <see cref="JsonConverter{T}"/> instance that converts <see cref="Half"/> values. 175public static JsonConverter<Half> HalfConverter => field ??= new HalfConverter();
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (1)
722potentialNumberType == typeof(Half) ||