Tedd.BitUtils 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tedd.BitUtils --version 1.0.2
                    
NuGet\Install-Package Tedd.BitUtils -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tedd.BitUtils" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tedd.BitUtils" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Tedd.BitUtils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tedd.BitUtils --version 1.0.2
                    
#r "nuget: Tedd.BitUtils, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Tedd.BitUtils&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Tedd.BitUtils&version=1.0.2
                    
Install as a Cake Tool

Tedd.BitUtils

Available as NuGet Package: https://www.nuget.org/packages/Tedd.BitUtils/

Bit manipulation extension methods for byte, short (Int16), ushort (UInt16), int (Int32), uint (UInt32), long (Int64) and ulong (UInt64).

Types can be manipulated in-place or by returning a modified copy. All methods are tagged for inline compile. Ror and Rol methods should be optimized by RyuJit to use CPU implementations.

Note that CPU most likely only supports bit manipulation on Int32 and Int64, so Byte and Int16 will be treated as Int32 internally. Result will be correct, but there is no speed benefit and possibly a small penalty for using smaller types than Int32.

Extensions

i can be byte, short (Int16), ushort (UInt16), int (Int32), uint (UInt32), long (Int64) and ulong (UInt64).

Faster versions of Ror() and Rol() are hardcoded to shift 1. Faster versions of SetBit0(n) and SetBit1(n) skips the branch required for SetBit(n, true/false).

Note: Ror and Rol is only implemented for 32-bit and 64-bit integers.

In-place

  • i.SetBit(n, bool);
  • i.SetBit0(n);
  • i.SetBit1(n);
  • i.Rol();
  • i.Rol(n);
  • i.Ror();
  • i.Ror(n);
  • i.ReverseBits();

Copy

  • bool = i.IsBitSet(n);
  • i.SetBitCopy(n, bool);
  • i.SetBit0Copy(n);
  • i.SetBit1Copy(n);
  • i.RolCopy();
  • i.RolCopy(n);
  • i.RorCopy();
  • i.RorCopy(n);
  • i.ReverseBits();

Quick examples

var a = 0;
a.SetBit(0, true);
// a == 1
a.SetBit(1, true);
// a == 3
a.SetBit0(0);
// a == 2
// a.IsBitSet(0) == false
var b = a.SetBit(0);
// b == 3
a = 1;
a.Rol();
// a == 3
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.0

    • No dependencies.
  • .NETCoreApp 2.1

    • No dependencies.
  • .NETCoreApp 3.0

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Tedd.BitUtils:

Package Downloads
schema

Library for converting classes to and from binary. Provides a C# Roslyn generator that automatically implements conversion logic for simple classes.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 2,286 2/25/2022
1.0.6 630 3/20/2020
1.0.5 613 12/15/2019
1.0.4 583 12/15/2019
1.0.3 543 12/8/2019
1.0.2 550 12/7/2019
1.0.1 555 11/8/2019
1.0.0 564 11/7/2019