Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
314 B
2
Indexable
Never
template<typename in_T>
void PrintBinary(in_T number)
{
	int size_of_type = sizeof(number) * 8;
	for (int digit_pos=0; digit_pos < size_of_type; digit_pos ++)
	{
		in_T digit = (in_T) 1 << (size_of_type - 1 - digit_pos);
		int value = (number & digit) ? 1 : 0;
		printf("%i", value);
	}
	printf("\n");
}