python整数二进制存储
Given an integer number and we have to print numbers of bits to store the number and its binary value.
给定一个整数,我们必须打印位数以存储数字及其二进制值。
Printing number of bits to store an integer
打印位数以存储整数
To find the total number of bits to store an integer, we use bit_length() function, it is called with the number (an integer value) and returns the total number of bits to store the given number.
要查找存储整数的位数,我们使用bit_length()函数 ,将其与数字(整数值)一起调用,并返回存储给定数字的位数。
Printing binary value
打印二进制值
To print binary value of a given integer, we use bin() function it accepts the number as an argument and returns the binary value.</