Top "Bit-manipulation" questions

The manipulation of individual bits.

How Does The Bitwise & (AND) Work In Java?

I was reading through some code examples and came across a & on Oracle's website on their Bitwise and Bit …

java bit-manipulation bit
Using bitwise OR 0 to floor a number

A colleague of mine stumbled upon a method to floor float numbers using a bitwise or: var a = 13.6 | 0; //a == 13 We …

javascript floating-point bit-manipulation
Find out number of bits needed to represent a positive integer in binary?

This is probably pretty basic, but to save me an hour or so of grief can anyone tell me how …

java bit-manipulation bits
Fastest way to get sign in Java?

I'd like to get the sign of a float value as an int value of -1 or 1. Avoiding conditionals is …

java optimization logic bit-manipulation
How is overflow detected in two's complement?

I see that when I subtract positive and negative number using two's complement I get overflows. For example, if I …

binary bit-manipulation twos-complement
How can I perform multiplication without the '*' operator?

I was just going through some basic stuff as I am learning C. I came upon a question to multiply …

java c++ c bit-manipulation
Change a bit of an integer

We have an integer number int x = 50; in binary, it's 00110010 How can I change the fourth (4th) bit programatically?

c++ c bit-manipulation bitwise-operators
Simplest way to check if two integers have same sign?

Which is the simplest way to check if two integers have same sign? Is there any short bitwise trick to …

integer bit-manipulation sign
How to add two numbers without using ++ or + or another arithmetic operator

How do I add two numbers without using ++ or + or any other arithmetic operator? It was a question asked a …

c++ c algorithm bit-manipulation