264 references to BitCast
System.Numerics.Tensors (2)
System\Numerics\Tensors\netcore\TensorPrimitives.ConvertHelpers.cs (2)
270public static float Invoke(short x) => (float)Unsafe.BitCast<short, Half>(x); 451public static ushort Invoke(float x) => Unsafe.BitCast<Half, ushort>((Half)x);
System.Private.CoreLib (260)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (8)
900public static unsafe long DoubleToInt64Bits(double value) => Unsafe.BitCast<double, long>(value); 908public static unsafe double Int64BitsToDouble(long value) => Unsafe.BitCast<long, double>(value); 916public static unsafe int SingleToInt32Bits(float value) => Unsafe.BitCast<float, int>(value); 924public static unsafe float Int32BitsToSingle(int value) => Unsafe.BitCast<int, float>(value); 949public static unsafe ulong DoubleToUInt64Bits(double value) => Unsafe.BitCast<double, ulong>(value); 958public static unsafe double UInt64BitsToDouble(ulong value) => Unsafe.BitCast<ulong, double>(value); 967public static unsafe uint SingleToUInt32Bits(float value) => Unsafe.BitCast<float, uint>(value); 976public static unsafe float UInt32BitsToSingle(uint value) => Unsafe.BitCast<uint, float>(value);
src\libraries\System.Private.CoreLib\src\System\Enum.cs (5)
1478return result ?? Unsafe.BitCast<TStorage, TUnderlying>(value).ToString()!; 1516result = Unsafe.BitCast<TStorage, TUnderlying>(value).ToString()!; 1868if (GetNameInlined(enumInfo, Unsafe.BitCast<TUnderlying, TStorage>(value)) is string enumName) 1883if (TryFormatFlagNames(enumInfo, Unsafe.BitCast<TUnderlying, TStorage>(value), destination, out charsWritten, ref destinationIsTooSmall) || destinationIsTooSmall) 1916if (TryFormatFlagNames(GetEnumInfo<TStorage>(enumType), Unsafe.BitCast<TUnderlying, TStorage>(value), destination, out charsWritten, ref destinationIsTooSmall) ||
src\libraries\System.Private.CoreLib\src\System\Half.cs (3)
749uint realMask = (uint)(Unsafe.BitCast<bool, sbyte>(float.IsNaN(value)) - 1); 1078uint subnormalMask = (uint)-Unsafe.BitCast<bool, byte>(offsetExponent == 0u); 1080int infinityOrNaNMask = Unsafe.BitCast<bool, byte>(offsetExponent == HalfExponentMask);
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.cs (160)
326Unsafe.BitCast<T, byte>(value), 333Unsafe.BitCast<T, short>(value), 340Unsafe.BitCast<T, int>(value), 347Unsafe.BitCast<T, long>(value), 370Unsafe.BitCast<T, byte>(value), 377Unsafe.BitCast<T, short>(value), 384Unsafe.BitCast<T, int>(value), 391Unsafe.BitCast<T, long>(value), 626Unsafe.BitCast<T, byte>(value), 632Unsafe.BitCast<T, short>(value), 638Unsafe.BitCast<T, int>(value), 644Unsafe.BitCast<T, long>(value), 693Unsafe.BitCast<T, byte>(value), 700Unsafe.BitCast<T, short>(value), 707Unsafe.BitCast<T, int>(value), 714Unsafe.BitCast<T, long>(value), 829Unsafe.BitCast<T, byte>(value), 836Unsafe.BitCast<T, short>(value), 843Unsafe.BitCast<T, int>(value), 850Unsafe.BitCast<T, long>(value), 876Unsafe.BitCast<T, byte>(value0), 877Unsafe.BitCast<T, byte>(value1), 884Unsafe.BitCast<T, short>(value0), 885Unsafe.BitCast<T, short>(value1), 912Unsafe.BitCast<T, byte>(value0), 913Unsafe.BitCast<T, byte>(value1), 914Unsafe.BitCast<T, byte>(value2), 921Unsafe.BitCast<T, short>(value0), 922Unsafe.BitCast<T, short>(value1), 923Unsafe.BitCast<T, short>(value2), 940Unsafe.BitCast<T, byte>(value0), 941Unsafe.BitCast<T, byte>(value1), 942Unsafe.BitCast<T, byte>(value2), 943Unsafe.BitCast<T, byte>(value3), 950Unsafe.BitCast<T, short>(value0), 951Unsafe.BitCast<T, short>(value1), 952Unsafe.BitCast<T, short>(value2), 953Unsafe.BitCast<T, short>(value3), 1138Unsafe.BitCast<T, byte>(value), 1145Unsafe.BitCast<T, short>(value), 1152Unsafe.BitCast<T, int>(value), 1159Unsafe.BitCast<T, long>(value), 1185Unsafe.BitCast<T, byte>(value0), 1186Unsafe.BitCast<T, byte>(value1), 1193Unsafe.BitCast<T, short>(value0), 1194Unsafe.BitCast<T, short>(value1), 1221Unsafe.BitCast<T, byte>(value0), 1222Unsafe.BitCast<T, byte>(value1), 1223Unsafe.BitCast<T, byte>(value2), 1230Unsafe.BitCast<T, short>(value0), 1231Unsafe.BitCast<T, short>(value1), 1232Unsafe.BitCast<T, short>(value2), 1249Unsafe.BitCast<T, byte>(value0), 1250Unsafe.BitCast<T, byte>(value1), 1251Unsafe.BitCast<T, byte>(value2), 1252Unsafe.BitCast<T, byte>(value3), 1259Unsafe.BitCast<T, short>(value0), 1260Unsafe.BitCast<T, short>(value1), 1261Unsafe.BitCast<T, short>(value2), 1262Unsafe.BitCast<T, short>(value3), 1402Unsafe.BitCast<T, byte>(lowInclusive), 1403Unsafe.BitCast<T, byte>(highInclusive), 1411Unsafe.BitCast<T, ushort>(lowInclusive), 1412Unsafe.BitCast<T, ushort>(highInclusive), 1420Unsafe.BitCast<T, uint>(lowInclusive), 1421Unsafe.BitCast<T, uint>(highInclusive), 1429Unsafe.BitCast<T, ulong>(lowInclusive), 1430Unsafe.BitCast<T, ulong>(highInclusive), 1468Unsafe.BitCast<T, byte>(lowInclusive), 1469Unsafe.BitCast<T, byte>(highInclusive), 1477Unsafe.BitCast<T, ushort>(lowInclusive), 1478Unsafe.BitCast<T, ushort>(highInclusive), 1486Unsafe.BitCast<T, uint>(lowInclusive), 1487Unsafe.BitCast<T, uint>(highInclusive), 1495Unsafe.BitCast<T, ulong>(lowInclusive), 1496Unsafe.BitCast<T, ulong>(highInclusive), 1534Unsafe.BitCast<T, byte>(lowInclusive), 1535Unsafe.BitCast<T, byte>(highInclusive), 1543Unsafe.BitCast<T, ushort>(lowInclusive), 1544Unsafe.BitCast<T, ushort>(highInclusive), 1552Unsafe.BitCast<T, uint>(lowInclusive), 1553Unsafe.BitCast<T, uint>(highInclusive), 1561Unsafe.BitCast<T, ulong>(lowInclusive), 1562Unsafe.BitCast<T, ulong>(highInclusive), 1600Unsafe.BitCast<T, byte>(lowInclusive), 1601Unsafe.BitCast<T, byte>(highInclusive), 1609Unsafe.BitCast<T, ushort>(lowInclusive), 1610Unsafe.BitCast<T, ushort>(highInclusive), 1618Unsafe.BitCast<T, uint>(lowInclusive), 1619Unsafe.BitCast<T, uint>(highInclusive), 1627Unsafe.BitCast<T, ulong>(lowInclusive), 1628Unsafe.BitCast<T, ulong>(highInclusive), 1705Unsafe.BitCast<T, byte>(value), 1711Unsafe.BitCast<T, short>(value), 1717Unsafe.BitCast<T, int>(value), 1723Unsafe.BitCast<T, long>(value), 1772Unsafe.BitCast<T, byte>(value), 1779Unsafe.BitCast<T, short>(value), 1786Unsafe.BitCast<T, int>(value), 1793Unsafe.BitCast<T, long>(value), 1847Unsafe.BitCast<T, byte>(value0), 1848Unsafe.BitCast<T, byte>(value1), 1855Unsafe.BitCast<T, short>(value0), 1856Unsafe.BitCast<T, short>(value1), 1880Unsafe.BitCast<T, byte>(value0), 1881Unsafe.BitCast<T, byte>(value1), 1882Unsafe.BitCast<T, byte>(value2), 1889Unsafe.BitCast<T, short>(value0), 1890Unsafe.BitCast<T, short>(value1), 1891Unsafe.BitCast<T, short>(value2), 1941Unsafe.BitCast<T, byte>(value0), 1942Unsafe.BitCast<T, byte>(value1), 1949Unsafe.BitCast<T, short>(value0), 1950Unsafe.BitCast<T, short>(value1), 1974Unsafe.BitCast<T, byte>(value0), 1975Unsafe.BitCast<T, byte>(value1), 1976Unsafe.BitCast<T, byte>(value2), 1983Unsafe.BitCast<T, short>(value0), 1984Unsafe.BitCast<T, short>(value1), 1985Unsafe.BitCast<T, short>(value2), 2153Unsafe.BitCast<T, byte>(value0), 2154Unsafe.BitCast<T, byte>(value1), 2161Unsafe.BitCast<T, short>(value0), 2162Unsafe.BitCast<T, short>(value1), 2186Unsafe.BitCast<T, byte>(value0), 2187Unsafe.BitCast<T, byte>(value1), 2188Unsafe.BitCast<T, byte>(value2), 2195Unsafe.BitCast<T, short>(value0), 2196Unsafe.BitCast<T, short>(value1), 2197Unsafe.BitCast<T, short>(value2), 2238Unsafe.BitCast<T, byte>(value0), 2239Unsafe.BitCast<T, byte>(value1), 2246Unsafe.BitCast<T, short>(value0), 2247Unsafe.BitCast<T, short>(value1), 2271Unsafe.BitCast<T, byte>(value0), 2272Unsafe.BitCast<T, byte>(value1), 2273Unsafe.BitCast<T, byte>(value2), 2280Unsafe.BitCast<T, short>(value0), 2281Unsafe.BitCast<T, short>(value1), 2282Unsafe.BitCast<T, short>(value2), 3385Unsafe.BitCast<T, byte>(oldValue), 3386Unsafe.BitCast<T, byte>(newValue), 3397Unsafe.BitCast<T, ushort>(oldValue), 3398Unsafe.BitCast<T, ushort>(newValue), 3408Unsafe.BitCast<T, int>(oldValue), 3409Unsafe.BitCast<T, int>(newValue), 3419Unsafe.BitCast<T, long>(oldValue), 3420Unsafe.BitCast<T, long>(newValue), 3472Unsafe.BitCast<T, byte>(oldValue), 3473Unsafe.BitCast<T, byte>(newValue), 3483Unsafe.BitCast<T, ushort>(oldValue), 3484Unsafe.BitCast<T, ushort>(newValue), 3493Unsafe.BitCast<T, int>(oldValue), 3494Unsafe.BitCast<T, int>(newValue), 3503Unsafe.BitCast<T, long>(oldValue), 3504Unsafe.BitCast<T, long>(newValue), 3979Unsafe.BitCast<T, byte>(value), 3986Unsafe.BitCast<T, short>(value), 3993Unsafe.BitCast<T, int>(value), 4000Unsafe.BitCast<T, long>(value),
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\VectorMath.cs (58)
79TVectorUInt64 n = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(dn); 101TVectorDouble ret = poly * Unsafe.BitCast<TVectorUInt64, TVectorDouble>((n + TVectorUInt64.Create(V_DP64_BIAS)) << 52); 104if (TVectorUInt64.GreaterThanAny(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(TVectorDouble.Abs(x)), TVectorUInt64.Create(V_ARG_MAX))) 187TVectorUInt64 nl = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(dnl); 188TVectorUInt64 nu = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(dnu); 223Unsafe.BitCast<TVectorUInt64, TVectorDouble>(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(polyl) + (nl << 52)), 224Unsafe.BitCast<TVectorUInt64, TVectorDouble>(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(polyu) + (nu << 52)) 228if (TVectorUInt32.GreaterThanAny(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(TVectorSingle.Abs(x)), TVectorUInt32.Create(V_ARG_MAX))) 309TVectorUInt64 specialMask = TVectorUInt64.GreaterThanOrEqual(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_MIN), TVectorUInt64.Create(V_MAX - V_MIN)); 313TVectorInt64 xBits = Unsafe.BitCast<TVectorDouble, TVectorInt64>(x); 316TVectorDouble lessThanZeroMask = Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.LessThan(xBits, TVectorInt64.Zero)); 325TVectorDouble zeroMask = Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(xBits << 1, TVectorInt64.Zero)); 336| Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.GreaterThanOrEqual(xBits, TVectorInt64.Create((long)double.PositiveInfinityBits))); 339TVectorDouble subnormalMask = TVectorDouble.AndNot(Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), temp); 344Unsafe.BitCast<TVectorUInt64, TVectorDouble>(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x * 4503599627370496.0) - TVectorUInt64.Create(52ul << 52)), 348specialMask = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(temp); 352TVectorUInt64 vx = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_OFF); 353TVectorDouble n = ConvertToDouble<TVectorInt64, TVectorDouble>(Unsafe.BitCast<TVectorUInt64, TVectorInt64>(vx) >> 52); 357TVectorDouble r = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(vx) - TVectorDouble.One; 379Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), 464TVectorUInt32 specialMask = TVectorUInt32.GreaterThanOrEqual(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_MIN), TVectorUInt32.Create(V_MAX - V_MIN)); 493TVectorSingle subnormalMask = TVectorSingle.AndNot(Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask), temp); 497Unsafe.BitCast<TVectorUInt32, TVectorSingle>(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x * 8388608.0f) - TVectorUInt32.Create(23u << 23)), 501specialMask = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(temp); 504TVectorUInt32 vx = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_OFF); 505TVectorSingle n = ConvertToSingle<TVectorInt32, TVectorSingle>(Unsafe.BitCast<TVectorUInt32, TVectorInt32>(vx) >> 23); 509TVectorSingle r = Unsafe.BitCast<TVectorUInt32, TVectorSingle>(vx) - TVectorSingle.Create(1.0f); 522Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask), 589TVectorUInt64 specialMask = TVectorUInt64.GreaterThanOrEqual(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_MIN), TVectorUInt64.Create(V_MAX - V_MIN)); 593TVectorInt64 xBits = Unsafe.BitCast<TVectorDouble, TVectorInt64>(x); 596TVectorDouble lessThanZeroMask = Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.LessThan(xBits, TVectorInt64.Zero)); 605TVectorDouble zeroMask = Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(xBits << 1, TVectorInt64.Zero)); 616| Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.GreaterThanOrEqual(xBits, TVectorInt64.Create((long)double.PositiveInfinityBits))); 619TVectorDouble subnormalMask = TVectorDouble.AndNot(Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), temp); 624Unsafe.BitCast<TVectorUInt64, TVectorDouble>(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x * 4503599627370496.0) - TVectorUInt64.Create(52ul << 52)), 628specialMask = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(temp); 632TVectorUInt64 vx = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_OFF); 633TVectorDouble n = ConvertToDouble<TVectorInt64, TVectorDouble>(Unsafe.BitCast<TVectorUInt64, TVectorInt64>(vx) >> 52); 637TVectorDouble r = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(vx) - TVectorDouble.One; 659Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), 738TVectorUInt32 specialMask = TVectorUInt32.GreaterThanOrEqual(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_MIN), TVectorUInt32.Create(V_MAX - V_MIN)); 742TVectorInt32 xBits = Unsafe.BitCast<TVectorSingle, TVectorInt32>(x); 745TVectorSingle lessThanZeroMask = Unsafe.BitCast<TVectorInt32, TVectorSingle>(TVectorInt32.LessThan(xBits, TVectorInt32.Zero)); 754TVectorSingle zeroMask = Unsafe.BitCast<TVectorInt32, TVectorSingle>(TVectorInt32.Equals(xBits << 1, TVectorInt32.Zero)); 765| Unsafe.BitCast<TVectorInt32, TVectorSingle>(TVectorInt32.GreaterThanOrEqual(xBits, TVectorInt32.Create((int)float.PositiveInfinityBits))); 768TVectorSingle subnormalMask = TVectorSingle.AndNot(Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask), temp); 773Unsafe.BitCast<TVectorUInt32, TVectorSingle>(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x * 8388608.0f) - TVectorUInt32.Create(23u << 23)), 777specialMask = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(temp); 781TVectorUInt32 vx = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_OFF); 782TVectorSingle n = ConvertToSingle<TVectorInt32, TVectorSingle>(Unsafe.BitCast<TVectorUInt32, TVectorInt32>(vx) >> 23); 786TVectorSingle r = Unsafe.BitCast<TVectorUInt32, TVectorSingle>(vx) - TVectorSingle.One; 802Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask),
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Packed.cs (1)
30return Unsafe.BitCast<T, ushort>(value) - 1u < 254u;
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.T.cs (13)
1310return PackedSpanHelpers.Contains(ref Unsafe.As<T, short>(ref searchSpace), Unsafe.BitCast<T, short>(value), length); 1487? PackedSpanHelpers.IndexOf(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value), length) 1488: PackedSpanHelpers.IndexOfAnyExcept(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value), length); 1673char char0 = Unsafe.BitCast<TValue, char>(value0); 1674char char1 = Unsafe.BitCast<TValue, char>(value1); 1900? PackedSpanHelpers.IndexOfAny(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value0), Unsafe.BitCast<TValue, char>(value1), Unsafe.BitCast<TValue, char>(value2), length) 1901: PackedSpanHelpers.IndexOfAnyExcept(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value0), Unsafe.BitCast<TValue, char>(value1), Unsafe.BitCast<TValue, char>(value2), length); 3484char charLowInclusive = Unsafe.BitCast<T, char>(lowInclusive); 3485char charRange = (char)(Unsafe.BitCast<T, char>(highInclusive) - charLowInclusive);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.cs (2)
70? (Unsafe.BitCast<T, byte>(Unsafe.Add(ref searchSpace, j)) > 127) 71: (Unsafe.BitCast<T, char>(Unsafe.Add(ref searchSpace, j)) > 127))
src\libraries\System.Private.CoreLib\src\System\Threading\Interlocked.cs (10)
180=> Unsafe.BitCast<int, float>(Exchange(ref Unsafe.As<float, int>(ref location1), Unsafe.BitCast<float, int>(value))); 189=> Unsafe.BitCast<long, double>(Exchange(ref Unsafe.As<double, long>(ref location1), Unsafe.BitCast<double, long>(value))); 368=> Unsafe.BitCast<int, float>(CompareExchange(ref Unsafe.As<float, int>(ref location1), Unsafe.BitCast<float, int>(value), Unsafe.BitCast<float, int>(comparand))); 378=> Unsafe.BitCast<long, double>(CompareExchange(ref Unsafe.As<double, long>(ref location1), Unsafe.BitCast<double, long>(value), Unsafe.BitCast<double, long>(comparand)));
System.Threading.Tasks.Parallel (2)
System\Threading\Tasks\ParallelLoopState.cs (2)
364return Unsafe.BitCast<int, TInt>(Volatile.Read(ref Unsafe.As<TInt, int>(ref _lowestBreakIteration))); 368return Unsafe.BitCast<long, TInt>(Volatile.Read(ref Unsafe.As<TInt, long>(ref _lowestBreakIteration)));