|
-
Using a mask
I'm working with a cool program from a book that uses a mask to print an integer's binary equivalent. I've never used a mask before so it's kind of new to me. If my integer is 123(0111 1011) and my mask value is defined initially as 1000 0000(which is 128), then the first time through the compiler is doing this:
0
1
Then it prints a 0 since 0 AND 1 gives you 0. Then I right shift my mask value over to the right by one place so my mask value is 0100 0000. Then I go again:
1
1
This time it prints a 1 because 1 AND 1 gives you a 1. Then I shift my mask value over to the right one place again so it looks like 0010 0000. Then I go again:
1
1
This time it again prints a 1 since 1 AND 1 gives you a 1. This process repeats until done and the loop terminates.
My question is you can see that the compiler is working with only one column at a time. It's working with the column that has the 1 bit in the mask value. What's the reason for this? Is this why they call it a mask? Because when you put 0's in all the other positions of your mask, the compiler ignores or becomes blind to those other neighboring columns?
Similar Threads
-
Replies: 2
Last Post: 06-03-2002, 03:23 PM
-
By bob in forum VB Classic
Replies: 0
Last Post: 03-24-2002, 11:55 PM
-
By cb in forum VB Classic
Replies: 0
Last Post: 10-25-2001, 10:14 AM
-
By Barend Esterhuizen in forum VB Classic
Replies: 1
Last Post: 11-30-2000, 07:45 AM
-
By Bryan in forum VB Classic
Replies: 0
Last Post: 06-30-2000, 05:38 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks