Bitwise operations: online resources? - bit-manipulation

Is there a nice e-book (preferably PDF, like Array and Pointers in C) explaining bitwise operations? Other resources also welcome, but I'm after a self-contained document, if possible.
Thanks

This isn't an ebook, but it's more of a "cookbook" of many applications of bitwise operations: Bit Twiddling Hacks.

Related

what is the Difference between Bit masks and bit manipulation?

any one can give me answer to this Question ! is Bit Masks and Bit Manipulation are same topics ? or different ?
Bitmasks are a type of bit manipulation, usually performed using the bitwise AND operator to read or clear a specific number of bits. It can also refer to setting, clearing, and toggling individual bits in a bit field. Good resources for learning about bit manipulation (as you requested): Bitwise operations, Bit Twiddling Hacks, Bit manipulation, and Masks.

Bit-wise operators and bit manipulation

I am new at using bit-wise operators and manipulating bits and I was wondering if someone knows some techniques or something that will help me to learn to do this properly.
Maybe some book or something that explains this well and how to apply it.
I highly recommend these resources:
Representation of Numbers
Binary Arithmetic
Low Level Bit Hacks You Absolutely Must Know
and absolute classic
Bit Twiddling Hacks

Solving Concurrency using arrays in C++ and POSIX

I'm looking for any guidance on how to solve concurrency problem that will emerge when two processes are trying to access a shared resource (text file). The solution must use an algorithm and an array as a data structure to coordinate and arrange the execution of these two processes to solve concurrency.
I'm using C++ and POSIX API and I have read about several solutions to solve concurrency, but they use semaphores, locks and other methods but not arrays. Any guidance on how to do it using arrays?
I suspect you are being asked to produce an implementation of Peterson's algorithm (or similar). This uses an integer and an array of booleans to implement a mutex, without requiring any platform support for synchronisation/atomic operations.

Bit manipulations/operations calculator?

I am getting into bit manipulation in C/C++.
Is there a good calculator or program (executable or online), that makes it relatively convenient to study & test bit procedures?
I can do same work in Visual Studio or Eclipse, but relatively small program is easier and more convenient.
I use bincalc by Ding Zhaojie. It conveniently lets you see what's going on in hex and binary (and decimal if you care), and has a nice gadget for inputting binary or flipping bits.
http://sites.google.com/site/bincalc/
Free, but no source.
The calculator, calc, in Windows 7 has a 'Programmer' view (Alt + 3). It has most of the operations for bit manipulations.
bitwisecmd.com Supports conversion from decimal to binary and hehadecimal numbers as well as basic bitwise operations as AND, OR, XOR, NOT, left shift, right shift. Neatly arranges bits in binary numbers so you can see how this stuff works.
I use a good online tool that supports all the bitwise operations, so you don't need to install anything: http://www.convertforfree.com/bitwise-calculator/
This tool saved me a lot of time and effort.
Use this tool. It has a free online truth table generator as well as a calculator for bitwise operations.

Open source C++ library for vector mathematics

I would need some basic vector mathematics constructs in an application. Dot product, cross product. Finding the intersection of lines, that kind of stuff.
I can do this by myself (in fact, have already) but isn't there a "standard" to use so bugs and possible optimizations would not be on me?
Boost does not have it. Their mathematics part is about statistical functions, as far as I was able to see.
Addendum:
Boost 1.37 indeed seems to have this. They also gracefully introduce a number of other solutions at the field, and why they still went and did their own. I like that.
Re-check that ol'good friend of C++ programmers called Boost. It has a linear algebra package that may well suits your needs.
I've not tested it, but the C++ eigen library is becoming increasingly more popular these days. According to them, they are on par with the fastest libraries around there and their API looks quite neat to me.
Armadillo
Armadillo employs a delayed evaluation
approach to combine several operations
into one and reduce (or eliminate) the
need for temporaries. Where
applicable, the order of operations is
optimised. Delayed evaluation and
optimisation are achieved through
recursive templates and template
meta-programming.
While chained operations such as
addition, subtraction and
multiplication (matrix and
element-wise) are the primary targets
for speed-up opportunities, other
operations, such as manipulation of
submatrices, can also be optimised.
Care was taken to maintain efficiency
for both "small" and "big" matrices.
I would stay away from using NRC code for anything other than learning the concepts.
I think what you are looking for is Blitz++
Check www.netlib.org, which is maintained by Oak Ridge National Lab and the University of Tennessee. You can search for numerical packages there. There's also Numerical Recipes in C++, which has code that goes with it, but the C++ version of the book is somewhat expensive and I've heard the code described as "terrible." The C and FORTRAN versions are free, and the associated code is quite good.
There is a nice Vector library for 3d graphics in the prophecy SDK:
Check out http://www.twilight3d.com/downloads.html
For linear algebra: try JAMA/TNT . That would cover dot products. (+matrix factoring and other stuff) As far as vector cross products (really valid only for 3D, otherwise I think you get into tensors), I'm not sure.
For an extremely lightweight (single .h file) library, check out CImg. It's geared towards image processing, but has no problem handling vectors.