Questions tagged as 'bit'

1
answer

What is the ~ (useful) operator in PHP?

What is the ~ (useful) operator in PHP? I have seen things like: echo ~PHP_INT_MAX Until then I thought it was to "reverse" a negative number or something, but with the tests I saw that I was wrong. Example: echo ~2; //Imprim...
asked by 03.08.2015 / 17:12
8
answers

How to know all possible combinations of 0 and 1 in Java?

What combinations can you get only with 0 and 1 numbers using 5 boxes (digits)? For example: 00000 00001 00011 ... 11111. I wanted to save all the combinations, but I do not know how to find all of them.     
asked by 17.05.2017 / 15:26
2
answers

How does bit shift work in C / C ++?

I'd like to understand how bit shifting works in C / C ++ . I would also like to understand how the processor performs the calculations and how it handles all of this. I have some examples in C / C ++ : void USART_Init(unsigned int ubrr0)...
asked by 22.03.2014 / 15:08
1
answer

What is the ":" (two points) used for in the declaration of a member of a structure?

I saw this: typedef struct { unsigned char a : 1; unsigned char b : 7; } Tipo; What does this statement mean? What is this 1 and 7?     
asked by 20.01.2017 / 13:24
1
answer

How to connect a bit to a number?

There are situations where we use numbers to load flags , meaning each bit, or set of bits, means something. Or we need to manipulate some data according to their bits, maybe it has to do with colors or something that bits individually end up h...
asked by 05.01.2017 / 11:54
1
answer

Minimum bits needed to represent a natural number

What is the most performative way of finding the minimum number of bits needed to represent a natural number (i.e., no signal) in JavaScript? Is there a way to do without using loops? The code below for example works for every integer between...
asked by 26.07.2014 / 17:29
1
answer

Get the least significant bit of an integer in Java

I'm trying to do a bit manipulation in java, but I'm having a problem. I'm storing any number in an int and trying to get the least significant bit of it, but I do not know how to do that. For example: int valor = 98; The value in bin...
asked by 11.07.2018 / 01:49
2
answers

How to replace 1 bit of an integer without changing the other neighboring bits?

I want to change 1 bit and keep the same values as other neighboring bits. The bit operator shifts left or right by changing the 1-bit 0 bit, but it changes the entire 8-bit sequence. I did not want that to happen. Alternatively, I change...
asked by 18.06.2017 / 20:57
1
answer

Bitwise operation

In my first semester of college I made an algorithm to avoid wasting memory, just for testing. Now I'm passing this code to C: Here is the whole code: // 8 bits // Aguenta até 4 slots (0 - 3) // Valor inteiro máximo suportado: 255 void...
asked by 16.03.2017 / 17:49
1
answer

Boolean Array for Integer

How can I transform a boolean array, boolean[] bits into its corresponding Integer ? I have a function that does exactly the opposite, but I did not understand it enough to be able to invert it. int input = 62; boolean[] bits...
asked by 31.08.2017 / 21:13