Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Bit Manipulation Library

In response to the Grapical GET/SET Bit suggestion on the Idea Exchange, I created this library.

What's this for?

To  create a fast, maybe someday universal, library for getting and setting bits in a numeric.  It's supposed to be a simple solution to a common problem so you don't have to think about ANDs, ORs, and NOTs.

Features (yeah, seriously)

  • Get and set  bits in any integral numeric type (U8, U16, U32, U64, I8, I16, I32,  I64).
  • It's fast.  I can get 300-700 million bit sets per second on my machine (test it on your machine with the attached project files!)
  • It's easy to use.  You just drop one of two VIs: Get Bit(s) or Set Bit(s).  They're polymorphic VIs, so they'll adapt to whatever numeric type you wire in.
  • It supports setting and clearing single bits or sets of bits (you can wire in a single bit or an array of bits to set)
  • It's really fast.  It uses VI inlining, introduced in LabVIEW 2010

This library works best in LabVIEW 2010.  If you were to  save it for LabVIEW 2009 or earlier it would work about 300 times slower.

This is the fastest implementation I could come up with, but then again I didn't try too hard. If you can come up with something faster, let me know and I'll try to incorporate it.

I've attached two files:

  1. BitManipulationSourceDist.zip: Use this for developing applications
  2. BitManipulationProject.zip: Use this for seeing my speed test and correctness test.  You should also use this if you think you can make a faster version.

Feedback is always welcome.

Notes:

Version 4: Updated Test VI to make sure that inlined code is called every time

-- Mike
Download All
Comments
James_McN
Active Participant Active Participant
Active Participant
on

Hey,

Nice library.  If you were interested just tested on a top spec Dell Precision T3500 (Quad Core Xeon @ 2.8GHz) and managed 1.21 Billion Bit sets per second with your test VI.

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Mr.Mike
NI Employee (retired)
on

I tested it on a T3500 with a quad core Xeon 2.67 and peaked around 900M.  I wonder why you got so much better performance.  I'll try again when my machine isn't under such a high load.

-- Mike
Contributors