Returns how many bytes are required to hold a certain number of bits - CSharp System

CSharp examples for System:Byte

Description

Returns how many bytes are required to hold a certain number of bits

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from  w ww . java2 s .c  o m

public class Main{
        /// <summary>
        /// Returns how many bytes are required to hold a certain number of bits
        /// </summary>
        public static int BytesToHoldBits(int numBits)
        {
            return (numBits + 7) / 8;
        }
}

Related Tutorials