我想了解這個代碼,它反轉O(n)時間的位。我瞭解時間複雜性,但我無法理解此代碼背後的邏輯。 public static long reverse(long a) {
long result = 0;
int i = 31;
while(a > 0){
result += (a % 2) * Math.pow(2, i);
i--;
我有一個任務,需要我將浮點數轉換爲IEEE 754二進制表示。我已經完成了部分部分,但我不知道如何將數字分解成部分(信號,指數和分數)。這裏是我有的代碼: typedef unsigned char Byte;
void showbits(char str[], Byte data[], int size) {
int i, j;
int bit;
pri
比方說,我在Ada的創建類型: type Coord_Type is range -32 .. 31;
我能想到位,發送該值到另一個系統時,看起來像在內存中,或特別? 我可以考慮兩種選擇。 其中之一是全部(默認整數?)空間用於「Coord_Type」的所有變量,但只有該範圍內的值是可能的。如果我假設二進制補碼,然後,值25和-25將是可能的,但不是50或-50: 0000 0000 0001
我想用盡可能小的空間將System.currentTimeInMillis存儲在內存中。因爲我必須將數百萬個數據存儲在內存中。 我把它轉化爲binaryString這給了我41 bits 這裏是我的程序 public class BitSetSize {
public static void main(final String[] args) {
final long cur
我已經試過幾乎所有的資源設置爲1的位數 but i could not solve this ("return the number of bits set to 1 in the binary representation of the number A*B"
我的問題是,用來計算有多少數據結構1是他們的二進制a * b,編程式