'Declaration
Public Shared Function MinBits( _
ByVal number As System.UInteger, _
ByVal sign As System.UShort _
) As System.UInteger
public static System.uint MinBits(
System.uint number,
System.ushort sign
)
Parameters
number
The numbe to be calculated.
sign
1 or 0 to indicates whether the number is a signed value or not.
Remarks
The number should be given in its unsigned form with the flag sign equal to 1 if it is signed. Repeatedly compares number to another unsigned int called x. x is initialized to 1. The value of x is shifted left i times until x is greater than number. Now i is equal to the number of bits the UNSIGNED value of number needs. The signed value will need one more bit for the sign so i+1 is returned if the number is signed, and i is returned if the number is unsigned.