• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lduchosal / ipnetwork / 960

15 May 2026 07:18AM UTC coverage: 0.0% (-94.1%) from 94.053%
960

Pull #411

appveyor

web-flow
Merge ef6b054ce into 4cec191ae
Pull Request #411: Bump MSTest.TestFramework from 4.2.2 to 4.2.3

0 of 2438 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/System.Net.IPNetwork/IPNetwork2BitsSet.cs
1
// <copyright file="IPNetwork2BitsSet.cs" company="IPNetwork">
2
// Copyright (c) IPNetwork. All rights reserved.
3
// </copyright>
4

5
namespace System.Net;
6

7
using System.Numerics;
8

9
/// <summary>
10
/// BitSet.
11
/// </summary>
12
public sealed partial class IPNetwork2
13
{
14
    /// <summary>
15
    /// Count bits set to 1 in netmask.
16
    /// </summary>
17
    /// <param name="netmask">A number representing the netmask to count bits from.</param>
18
    /// <returns>The number of bytes set to 1.</returns>
19
    [CLSCompliant(false)]
20
    public static uint BitsSet(IPAddress netmask)
21
    {
×
22
        var uintNetmask = ToBigInteger(netmask);
×
23
        uint bits = BitsSet(uintNetmask);
×
24

25
        return bits;
×
26
    }
×
27

28
    /// <summary>
29
    /// Count bits set to 1 in netmask.
30
    /// </summary>
31
    /// <see href="http://stackoverflow.com/questions/109023/best-algorithm-to-count-the-number-of-set-bits-in-a-32-bit-integer"/>
32
    /// <param name="netmask">A number representing the netmask to count bits from.</param>
33
    /// <returns>The number of bytes set to 1.</returns>
34
    private static byte BitsSet(BigInteger netmask)
35
    {
×
36
        string s = netmask.ToBinaryString();
×
37

38
        return (byte)s.Replace("0", string.Empty)
×
39
            .ToCharArray()
×
40
            .Length;
×
41
    }
×
42
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc