-
as seen on Stack Overflow
- Search for 'Stack Overflow'
In a sequence of length n, where n=2k+3, that is there are k unique numbers appeared twice, how to find the three unique numbers that appeared only once using bit manipulation?
for example, in sequence 1 1 2 6 3 6 5 7 7 the three unique numbers are 2 3 5.
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I didn't know any better name for a title of the question.
For ex: on one of my previous questions one answered ((a)-(b))&0x80000000) 31 - this is kind of a too advanced for me and i can't really get what it means. I am not looking just for an answer of that, but i need someone to tell me some…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi.
I am trying to make a loop that loops through all different integers where exactly 10 of the last 40 bits are set high, the rest set low. The reason is that I have a map with 40 different values, and I want to sum all different ways ten of these values can be multiplied. (This is just out of…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I have a fragment of bytes in a byte[]. The total size of the array is 4 and I want to convert this into a positive long number. For example if the byte array is having four bytes 101, 110, 10, 1 then i want to get the long number represented by binary sequence
00000000 00000000 00000000 00000000…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi,
I am stuck with a problem. I am working on a hardware which only does support 32 bit operations.
sizeof(int64_t) is 4. Sizeof(int) is 4.
and I am porting an application which assumes size of int64_t to be 8 bytes. The problem is it has this macro
BIG_MULL(a,b) ( (int64_t)(a) *…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Java has 2 bitshift operators for right shifts:
>> shifts right, and is dependant on the sign bit for the sign of the result
>>> shifts right and shifts a zero into leftmost bits
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op3.html
This seems fairly simple, so can…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi all, I discovered something odd that I can't explain. If someone here can see what or why this is happening I'd like to know. What I'm doing is taking an unsigned short containing 12 bits aligned high like this:
1111 1111 1111 0000
I then want to shif the bits so that each byte in the short hold…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I've got a really big number: 5799218898. And want to shift it right to 13 bits.
So, windows-calculator or python gives me:
5799218898 13 | 100010100100001110011111100001 13
70791 | 10001010010000111
As expected.
But Javascript:
5799218898 13 | 100010100100001110011111100001 …
>>> More
-
as seen on ASP.net Weblogs
- Search for 'ASP.net Weblogs'
So I was doing some reading tonight on my Nerdkit , I had planned to actually do some playing around with it, but decided just to read a bit. I’ve never coded in C, I did C++ in College (not very well) and do most of my development in C# these days (when I’m doing code, mostly for fun). While all…
>>> More
-
as seen on Programmers
- Search for 'Programmers'
I'm implementing a 16-bit left bit shift by r bits, and I only have access to AND, NOT and ADD. There are 3 condition codes, negative, zero and positive, which are set when you use any of these operations.
How I went about it was :
(1) And the number with 1000 0000 0000 0000 to set condition codes…
>>> More