bits

mix N bits with next N bits (e.g each 4bits) 00001111 -> 01010101

As the title of this question tells I want to know the best way to mix blocks of bits within an integer (especially 64bit unsigned) for example I have 8bit integer, where it's bits are 0000 1111 mix 4bits by 4 bits = 0101 0101 example 2: 0010 0110 0 1 1 0 right *0.0.1.0 left* = 00011100 mix 4bits by 4 bits = 0001...

The showbits() function.

While reading a book called "Let us C" I read that a function showbit() exists which can show you the bits of the number. There wasn't any special header file mentioned for it. Searched for it on the internet and didn't found anything useful. Is there such a function? I want this to print the binary of decimal numbers. Else please give m...

Extract bit sequences of arbitrary length from byte[] array efficiently

I'm looking for the most efficient way of extracting (unsigned) bit sequences of arbitrary length (0 <= length <= 16) at arbitrary position. The skeleton class show how my current implementation essentially handles the problem: public abstract class BitArray { byte[] bytes = new byte[2048]; int bitGet; public BitArray() { } public vo...

P/Invoke declaration does not seem correct

I was handed down a library that was developed in house as a wrapper for BITS. I was told that if you wanted to change between the 64bit and 32bit build you would need to swap out these two commented lines. [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)] //32 bit address internal struct BG_BASIC_CREDENTIALS { [FieldOffset(0...

Reading and Writing Bits to Text Files in Java

I'm trying to implement some compression algorithms, and I need to deal with bits in Java. What I need to do is that when I write the value 1 then the value 2, those numbers are stored in the file as bits, so the file size will be 1 byte instead of 2, as 1 is stored in 1 bit and 2 is stored in 2 bits. Is it possible? Thanks very much ...

Non-binary(hex) characters in string received over TCP with Python

Hi, maybe this is a noob question, but I'm receiving some data over TCP and when I look at the string I get the following: \x00\r\xeb\x00\x00\x00\x00\x01t\x00 What is that \r character, and what does the t in \x01t mean? I've tried Googling, but I'm not sure what to Google for... thanks. ...

BITS Upload giving me error 0x80190194

I am uploading files to IIS 7 using BITS it works flawlessly and fine except for certain files when it fails 100% iwth 0x80190194 which is HTTP 404 which amkes no sense to me in terms of remote url not found I am using the sharpbits library whats amazing is that some files work and some dont and no its not a size thing the failing file ...

C#: Manual bit conversion?

Is there a better way to write this than using BitConverter? public static class ByteArrayExtensions { public static int IntFromUInt24(this byte[] bytes) { if (bytes == null) { throw new ArgumentNullException(); } if (bytes.Length != 3) { throw new ArgumentOutOfRa...

C# Why does 127 = this bit string?

Given this code which prints all the bits in an integer out: private string getBitLiteral(bool bitVal) { if (bitVal) { return ("1"); } else { return ("0"); } }   Int64 intThisHand = 127; for (int i = 64; i > 0; i--) { HttpContext.Current.Response.Write( getBitLi...

How to determine if a number is positive or negative in Java?

I was asked this question in Amazon Chennai(India) interview , to determine whether an number is positive or negative. The rules are that , we should not use conditional operators such as <, and >, built in java functions (like substring, indexOf, charAt, and startsWith), no regex, or API's. I did some homework on this and the code is gi...

SharpBITS apparent bug

Anyone here uses SharpBITS? Apparently there is a bug in SharpBITS, when you open SharpBITS GUI, create a job, exit the application, open the application again, then cancel the transferring job. Then you cannot anymore create the same job as the status of that will be suspended and for some reason it will not resume. Anybody experienced...

Java Working with bits

Let me start by saying I have never really worked with bits before in programming. I have an object that can be in 3 states and I want to represent those states using a 3 bit array. For example: I have a race car and it can go forward,left, and right at a stand still the bits would be 000 If the car was moving forward the bits would b...

Performing a logical not ! using only bitwise operations.

Possible Duplicate: Check if a number is non zero using bitwise operators in C. Hello everyone, I am working on a project and I need a little help with a function. We need to write a function that performs the logical not, !, using only the following bitwise operators: ~ & ^ | + << >> I'm not even sure where to begin. ...