How to rounds and uint32 value up to a power of two 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)
        {
            uint value = 300; 

            uint result = BitOperations.RoundUpToPowerOf2(value);

            MessageBox.Show(result.ToString());
        }
    }
}




/*
run:
  
512
 
*/

 



answered Apr 9, 2024 by avibootz
...