Skip to content

Latest commit

 

History

History

bit-manipulation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

#Bit Manipulation Puzzles

This is a series of functions that utilize bit patterns to manipulate integers. Each function is limited to using only certain types of bit operations and a certain number of them.

There are three main categories of functions:

  1. Bit manipulation - functions that manipulate & test sets of bits

  2. Two's complement arithmetic - involve two's complement representations

  3. Floating point arithmetic - operations on bit-level representations of floating point numbers.

Some selected examples:

  • bang(x) - Compute !x without using !

  • float_f2i(f) - Given float f, compute (int) f

  • howManyBits(x) - Return the minimum number of bits needed to represent x in two's complement

All functions have a header containing a description & examples.