Bit Set

How do I check if a bit is set in C?
For example, I have a variable
int bits;
bits can be one of several values, eg
bits = BIT_1;
bits = BIT_2;
bits = BIT_1|BIT_2;
bits = BIT_1|BIT_3;
etc.
So first of all, how do I check if bits contains BIT_1? Or BIT_2? When it doesn’t matter if the other bits are on or off? And second, what is the value of bits when no bits are set? NULL? This is in C not C++
.The default value for an int is 0. Without giving it any other value, it will be zero.
Test the existence of a bit using the bitwise AND (&) operator.
if(bits&BIT_1) {
//then bits contains BITS_1
}
Ryan Reynolds Rage on Set of The Proposal
|
|
DRILL BIT SET $9.99 |
|
|
Door Lock Wood Flat Bit Hole Saw Set for Electric Drill $7.08 |
|
|
3 pc HINGE DRILL BIT SET Self Center Door Cabinet $8.99 |
|
|
3 pc HINGE DRILL BIT SET Self Center Door Cabinet $8.99 |
|
|
“NEW” COBALT DRILL BIT SET 21-PC $64.99 |
|
|
2 NEW, FIRST WATCH BIT KEY MORTISE LOCK SETS, DEADBOLTS $17.99 |
|
|
General MRCS Mini Rooter Bit Set $31.55 |
|
|
3 pc HINGE DRILL BIT SET Self Center Door Cabinet $8.99 |
|
|
3 SETS OF BIT KEY MORTISE LOCKS with Old Style Door Knobs – NEW- MAG Security $24.99 |
|
|
Irwin Short Length Speedbor 2000SL Spade Bit CHOICE OF SIZE New $13.89 |
|
|
New 100 Pc Security Bit Set Torx Star Security Screw Tamper Proof Free Ship $17.00 |
|
|
3 pc HINGE DRILL BIT SET Self Center Door Cabinet $8.99 |
|
|
Hanson Irwin Bright HSS Drill Bit & Tap Sets $8.95 |
|
|
Irwin Hanson Bright HSS Drill Bit & Screw Extractor Set $9.95 |
|
|
Irwin Hanson Bright HSS Drill Bit & Screw Extractor Set $14.95 |
|
|
Irwin Hanson Bright HSS Drill Bit & Screw Extractor Set $17.95 |
|
|
Bosch 38 Piece Magna Screw driving Bit Set MODEL T4038 NEW MUST HAVE $11.95 |
|
|
Bosch 2609255543 SDS-Plus Hammer Drill Bit Set (7 Pieces) $54.26 |
|
|
Draper Expert 48301 20-Piece Ratchet Screwdriver Socket and Bit Set $43.43 |
|
|
Wera 059298 Kraftform Kompakt 40 Bit Set (7 Pieces) $49.80 |
|
|
Draper 40850 70-Piece Screwdriver, Socket and Bit Set $43.14 |
|
|
Wera 059297 Kraftform Kompakt 62 Bit Set (33 Pieces) $133.26 |
|
|
Silverline 719769 4 Piece Kitchen Router Bit Set $31.54 |
|
|
Silverline SB08 9 Piece Extra Long Power Bit Set $8.66 |
|
|
Silverline DS51 25 Piece Drill Bit Set $24.69 |
|
|
Silverline 380647 3 Piece Hinge Drill Bit Set $15.40 |
|
|
Draper 72892 12-Piece 1/4-Inch TCT Router Bit Set $41.11 |
|
|
Door Lock Wood Flat Bit Hole Saw Set for Electric Drill $7.29 |
|
|
Door Lock Wood Flat Bit Hole Saw Set for Electric Drill $7.10 |
|
|
KS Tools TX-BIT Set 1/2″+1/4″+3/8″ Free Shipping $19.99 |
|
|
BLACK RHINO Magnetic Depth Bit Set 00063 $3.99 |
|
|
Door Lock Wood Flat Bit Hole Saw Set for Electric Drill $7.08 |
|
|
No 9 5 3 VIX BIT SET ~ CENTERING PILOT HOLE DRILL~ $34.99 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $3.69 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $3.79 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $3.89 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $4.19 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $4.39 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $4.49 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $4.59 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $4.69 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $4.89 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $4.99 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $5.09 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $5.19 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $5.69 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $6.09 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $6.59 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $6.69 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $7.39 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $21.99 |
|
|
Irwin Speedbor 2000 Spade Bit CHOICE OF SIZE or SET New $49.99 |
|
|
STANLEY 85-708 7-Piece 3⁄8″ Professional Grade Hex Bit Socket Set $34.81 |
|
|
5 PC ELITE INDUSTRIAL CARBIDE CHAMFER BIT SET 1/2 SHANK $33.24 |
|
|
Drill Bits and Anchors Set $15.96 |
|
|
NEW CMT 837.501.11 3 Piece Cove 12 Inch Shank Router Bit Set $91.79 |
|
|
New 100 Pc Security Bit Set Tamper Proof Free Ship $19.99 |
|
|
NEW 3 pc. 7/64″, 9/64″ & 11/64″ HSS Hinge Drill Bit Set $15.29 |
|
|
18 spade bits new in package 3 sets $10.00 |
|
|
6 router bit set vermont american black & decker freud $25.00 |
|
|
Black & Decker & Vermont American 21 brill bit set NEW $15.00 |
|
|
Black & Decker true value & irwin 19 drill bit set NEW $20.00 |
|
|
CAL VAN tools 16 pc set 1/4″ torx inserts & tamper bits $25.00 |
|
|
CAL VAN tools 7pc torx sockets & 7pc torx bit set $30.00 |
|
|
Draper 48681 8-Piece Precision Bit Set with LED $14.46 |
|
|
Faithfull Screwdriver Bit Set (31 Pieces) $24.37 |
|
|
Blue Spot 14151 Security Screwdriver Bit Set (33 Pieces) $7.97 |
|
|
Bosch 6 Piece SDS Plus Drill Bit Set $38.06 |
|
|
Bosch 5 Piece SDS Plus Drill Bit Set $32.74 |
|
|
Bosch 5pc Concrete Drill Bit Set $16.63 |
|
|
Rolson Tools 48550 10pc Flat Wood Drill Bit Set $22.49 |
|
|
Rolson Tools 30251 45pc Bit Set in Plastic Case $18.91 |
|
|
Draper 48843 11-in-1 Ratchet Screwdriver and Bit Set $18.11 |
|
|
Blue Spot 100 Piece Security Bit Set $18.83 |
|
|
Draper 78277 15-Piece 1/2-Inch Square Drive Draper Tx-Star Bit Set $28.43 |
|
|
Rolson Tools 36105 53pc Socket & Bit Set $35.86 |
|
|
Irwin 10502826 4X-Speed Blue Groove Flat Bit Set (6 Pieces) $47.74 |
|
|
Black and Decker A7187 Titanium Drilling and Screwdriver Bit Accessory Set (100 $73.17 |
|
|
Black and Decker A7184 Titanium Drilling and Screwdriver Bit Accessory Set (70 P $57.00 |
|
|
Black and Decker A7186 Titanium Drilling and Screwdriver Bit Accessory Set (16 P $23.77 |
|
|
Silverline 395024 75 mm Cobalt Drill Bit Set $8.40 |
|
|
Draper 40406 5-Piece Hollow Square Mortice and Chisel Bit Set $115.46 |
|
|
Silverline 598563 3 Piece HSS Taper Drill Bit Set $45.03 |
|
|
Silverline 282620 3 Piece HSS Step Drill Bit Set $52.29 |
|
|
Faithfull Woodworkers Drill Bit Set 21 Piece $45.66 |
|
|
Bahco 2058S26 Ratchet Socket Bit Set 26-Piece $53.31 |
|
|
Bahco 59S151 Bit Set PH / PZ / FL / TX (15 Pieces) $26.40 |
|
|
Faithfullfull Screwdriver Titanium Bit Set Cv 61Pc $22.57 |
|
|
Faithfull S2 Titanium Screwdriver Bit Set (17 Pieces) $26.37 |
|
|
Faithfull CASSET6 Combination Auger Bit Set 10-25mm Stubby (6 Pieces) $52.29 |
|
|
Wera 071112 Bit-Check BC 11/9 Rapidaptor Stainless Steel Set (9 Pieces) $74.71 |
|
|
Wera 059296 Kraftform Kompakt 61 Bit Set Specialist (17 Pieces) $89.14 |
|
|
Irwin Screwdriver Bit Set In Case 31PC $40.26 |
|
|
Silverline 633840 100 Piece Screwdriver Bit Set $12.66 |
|
|
Silverline 282566 6 Piece Flat Wood Drill Bit Set $13.51 |
|
|
Faithfull RBS15 Tungsten Carbide Router Bit Set and 1/2-inch Shank in Case (15 P $60.80 |
|
|
Wera Kraftform Kompakt 20 Sdriver Bit set $90.23 |
|
|
Bosch 2609255033 HSS-R Metal Drill Bit Set (19 Pieces) $45.20 |
|
|
Bosch 2609255032 HSS-R Metal Drill Bit Set (19 Pieces) $45.20 |
|
|
Bosch 2609255031 HSS-R Metal Drill Bit Set (13 Pieces) $14.43 |
|
|
Gerber Graduates BPA Free 6 Pack Soft Bite Infant Spoon, Colors May Vary $4.99 Nuk Soft Bite Infant Spoon – 6 pack Nuk Soft Bite Spoons are the perfect first spoon for your baby’s first bite of food. Features and Benefits -Soft, silicone tip spoons are gentle on mouth and gums for babies learning to eat -Long, slim handle makes feeding baby easier -Small tip fits easily in baby’s mouth Specifications Available in a variety color pack 6 pack … |
|
|
Wilton 2105-4923 24-Cavity Silicone Brownie-Squares Baking Mold $5.50 Bake fun shaped brownies, decorate, and add a stick for a unique brownie pop treat! Wilton Silicone Molds are flexible so removing your treats is easy, and are safe for freezer, oven (up to 500F/260C), microwave, and dishwasher. Stain and odor resistant. This package contains one silicone mold (13″ x 8-1/2″ x 1″) with (24) 1-1/2″ x 1-1/2″ cavities and one design. Brownie mix and sticks sold separa… |
|
|
Pez Lord of the Rings Gift Set $9.45 The Lord of the Rings Pez gift Set features 8 pez candy dispensers including Bilbo, Frodo, Sam, Gandalf, Aragorn, Legolas, Gimli and Gollum! This set looks fantastic and is a must have for Pez collectors, sci-fi collectors and Tolkien fans. This limited edition Pez dispenser gift set comes with 8 Lord of the Rings Pez dispensers and two 6 ct packages of Pez candy rolls…. |
|
|
The Ultimate Bee Gees (2 CD) $10.31 THE ULTIMATE BEE GEES is a double-disc career retrospective featuring the group’s many hits and chart-topping singles, performances of a selection of hit songs they wrote for others, and liner notes by Tim Rice.Tim Rice’s liner notes accompanying THE ULTIMATE BEE GEES puts the group’s extravagant popularity into perspective. ‘Within this package is a collection of performances and songs that very … |
|
|
The Dark Side Of The Moon – Immersion Box Set $79.24 Australia released, PAL/NTSC/Region 0 DVD: LANGUAGES: English ( Dolby Digital 5.1 ), English ( Dolby Digital Stereo ), English ( Dolby Linear PCM ), SPECIAL FEATURES: Booklet, Box Set, Collectors Edition, Interactive Menu, Multi-DVD Set, Photo Gallery, Remastered, Scene Access, SYNOPSIS: 6 Disc Box Set – 3 CDs; 2 DVDs & Blu-Ray Disc: The Immersion Edition inaugurating the series with a six-disc bo… |
|
|
The White Album (Remastered) $14.84 BEATLES THE ALBUM BLANCO (2CD) (EDICION LIMITADA)… |
|
|
Richard Simmons Sweatin’ to the Oldies [VHS] $7.43 Richard Simmons is the king of motivational exercise, especially if you’re a beginner. This video workout is a dance party simulating a class reunion, with an energizing live band playing lively hits from the ’50s and ’60s, such as “It’s My Party and I’ll Cry If I Want To,” “Great Balls of Fire,” and “Dancing in the Streets.” The singers and musicians sometimes come offstage and dance with the exe… |
|
|
A Year In Provence – Complete Set [VHS] $7.98 A Year in Provence, the made-for-TV version of the bestselling book by Peter Mayle, captures a year in the lives of Brits Mayle (John Thaw) and his wife Annie (Lindsay Duncan) in southern France. The Mayles both revel in and endure what for most would be a fantasy experience: leaving dull jobs, acquiring an old farmhouse in Provence, and (for Peter) attempting to write a novel in the midst of buco… |
|
|
Blue & The Gray (Original Uncut Version) [VHS] $8.45 Before Ken Burns, Glory, and Gettysburg, the Civil War proved an effective backdrop for this 1982 miniseries–available complete and uncut on this three-disc set–about two families divided by the War Between the States. John Hammond stars as John Geyser, a Southerner caught “betwixt and between” when he becomes a war correspondent for the Northern newspaper published by his uncle. Like a Civil Wa… |
|
|
SE 3 Pc. Power Extension Socket Bits for Drills $1.81 Add versatility to your power drills. 3pc Power Extension Socket Adaptor has Hex bit for all power drill chucks. Comes in 3 Sizes : 1/4 in. , 3/8 in. & 1/2 in.for your full range of sockets…. |
Tags: bit, bit set, bit setting, bitset c++, bitset in c, bitset java, c#, drill, programming, set
This entry was posted on Sunday, August 7th, 2005 at 7:23 pm and is filed under home improvement. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

