A Program for Bit-Slicing

I wrote this short program in C because I needed to do some bit-slicing in some homework. It's not too generic (accepts only 32 bit integers) but it can help in most cases.


An example usage of the program:

bs 0x12345678 31 4


Will give the following output:

0x12345678[31:4] = 0x1234567


You can download the source code (written in C) here: Bitslice Source Code 884 bytes


Compile it with gcc:

gcc -o bs bitslice.c


And add it to /usr/local/bin for easy access:

sudo cp bs /usr/local/bin/


Now you can use it from the command line this way:

bs 0x12345678 31 4


Enjoy :)

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

No related posts.

Tags: ,

Wednesday, June 10th, 2009 Tools

1 Comment to A Program for Bit-Slicing

  • Nishaad says:

    I am a student studying IB in India and i am doing my extended essay(small research) in Math. I need to generate large prime numbers (highest prime numbers of digits from 1-44). And i guess I’m hitting my cpu’s wall after 18 digits. Could u help me with this. I guess i’ll need to bit slice and generate a virtual 256 bit environment.
    Thanks.

    My system config:
    Processor: intel i7 920 @ 2.67 Ghz (4cores\8threads)
    Ram: 3 GB DDR3 1333 MHz
    Mobo: Asus P6T Deluxe
    OS: Vista Unlimate 32-bit.

  • Leave a Reply

    my email
    my photo
    Hi,
    My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
    I'm a Verification Engineer in Mellanox Technologies Ltd.
    I love Linux, the Command Line and the OpenSource Community.
    I used to write Poems (Arabic) when I was able to find time for this.
    June 2009
    S M T W T F S
    « May   Jul »
     123456
    78910111213
    14151617181920
    21222324252627
    282930  
    SEO Powered by Platinum SEO from Techblissonline

    Twitter links powered by Tweet This v1.7.4, a WordPress plugin for Twitter.