How to count the trailing zeros in a binary number using WinForms with C#

1 Answer

0 votes
using System.Numerics;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int number = 80; // 1010000

            MessageBox.Show("Number of Trailing Zeros: " + BitOperations.TrailingZeroCount(number));
        }
    }
}




/*
run:
 
Number of Trailing Zeros: 4
 
*/

 



answered Apr 7, 2024 by avibootz
...