forked from SixLabors/ImageSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitOperations.cs
More file actions
26 lines (24 loc) · 1013 Bytes
/
Copy pathBitOperations.cs
File metadata and controls
26 lines (24 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Runtime.CompilerServices;
#if !NETCOREAPP3_1_OR_GREATER
namespace SixLabors.ImageSharp.Common.Helpers
{
/// <summary>
/// Polyfill for System.Numerics.BitOperations class, introduced in .NET Core 3.0.
/// <see href="https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Numerics/BitOperations.cs"/>
/// </summary>
public static class BitOperations
{
/// <summary>
/// Rotates the specified value left by the specified number of bits.
/// </summary>
/// <param name="value">The value to rotate.</param>
/// <param name="offset">The number of bits to roate with.</param>
/// <returns>The rotated value.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint RotateLeft(uint value, int offset)
=> (value << offset) | (value >> (32 - offset));
}
}
#endif