Decimal To Binary

This algorithm converts decimal numbers to binary numbers.



									public static string DecimalToBinary(int dec)
{
	if (dec < 1) return "0";

	string binStr = string.Empty;

	while (dec > 0)
	{
		binStr = binStr.Insert(0, (dec % 2).ToString());
		dec /= 2;
	}

	return binStr;
}
								


Example

									int data = 6207166;
string value = DecimalToBinary(data);
								


Output

									10111101011011010111110