Skip to content

Expose nint/nuint overloads for BitOperations #54390

@tannergooding

Description

@tannergooding

Background and Motivation

Continuing with the theme of adding nint/nuint support to certain core locations (intrinsics, math, etc), it would be beneficial to add nint/nuint overloads for various BitOperations APIs. We are already defining and using a few of these internally.

Proposed API

namespace System.Numerics
{
    public static partial class BitOperations
    {
        public static bool IsPow2(nint value);
        public static bool IsPow2(nuint value);

        public static nuint RoundUpToPowerOf2(nuint value);

        public static int LeadingZeroCount(nuint value);

        public static int Log2(nuint value);

        public static int PopCount(nuint value);

        public static int TrailingZeroCount(nint value);
        public static int TrailingZeroCount(nuint value);

        public static nuint RotateLeft(nuint value, int offset);
        public static nuint RotateRight(nuint value, int offset);
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions