Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1440

For my link archive: Counting the leading zeroes and ones in a binary number with C#

$
0
0

From a while back, but still interesting:

  1. [Wayback/Archive] Counting the leading zeroes in a binary number with C#
  2. [Wayback/Archive] c# – Getting the number of leading 1 bits – Stack Overflow (thanks [Wayback/Archive] Barry Kelly and [Wayback/Archive] SoapBox)

Especially the first link explains the algorithm very well and is similar to links referred to from the Stack Overflow question as it is based on counting ones (and leading ones are basically leading zeros but bit-inverted).

It also explains a cool thing for leading zeros: modern CPU have instructions which .NET Core.

Via:

  1. [Wayback/Archive] Andrew Lock “Sock” on Twitter: “Blogged: Counting the leading zeroes in a binary number with C# #dotnet #dotnetcore #csharp”

  2. [Wayback/Archive] Jeroen Wiert Pluimers on Twitter: “@andrewlocknet Cool. This is kind of the opposite I asked a few years back a @StackOverflow”

References:

--jeroen


Viewing all articles
Browse latest Browse all 1440

Trending Articles