Data Quality Tools, Mailing Software, Lists, NCOA, Data Enhancements
  | Shopping Cart Cart | Newsletters | Search
Call 1-800-Melissa     Products         Solutions       Downloads & Trials       Support          Resources         Lookups       Contact Us  

 


 


Email Object Frequently Asked Questions

1. Email Object Concepts

       1.1 What are bitwise operations and why do I need to know them for
            Email Object?


  

 

    


FAQs

 

1.Email Object Concepts

          1.1 What are bitwise operations and why do I need to know
          them for Email Object?

A Bitwise operation uses a multi-bit type, commonly an integer, and operates at the level of its individual bits. More specifically, we are going to use bit masking when dealing with the Email Object ChangeCode property. Lets first discuss why we are using bitwise operations.

The Email Object ChangeCode indicates how the email address has been changed during verification. Currently, there are four possible changes: Syntax, Top Level Domain (TLD), Domain Spelling, and Domain Updated. Any combination of these changes can occur in an email address at once. Just based on these 4 possible changes, we have 15 different combinations of changes in an email address. If we add a 5th possible change, that number jumps to 31. To handle these possible changes combinations while accounting for future additions, we decided to use bitwise operations.

The ChangeCode property simply returns an integer. However, the actual information provided is at the bit level. The first bit corresponds to a syntax change, the 2nd bit to a TLD change, the 3rd to Domain Spelling, and 4th to Domain Update. If a specific change has occurred, we set that bit to 1, otherwise we leave it as 0. So, if the Domain Spelling and the syntax has changed, the ChangeCode becomes 0101 and we get the decimal equivalent of 5.

Now, to actually extract the information from the change code, we make use of bit masking. Bit masking isolates a specific bit so we can see if it is set or not. We do this by performing a logical AND operation on the change code and the bit mask for the bit we want to isolate. The bit mask is simply the integer equivalent of the change code in the Email Object guide, 1 for syntax, 2 for TLD, 4 for domain spelling, and 8 for domain update. Lets take a look at a bit masking example with a ChangeCode of 5(0101) and the bit mask for domain spelling, 4 (0100).

0101

AND 0100

= 0100

As you can see, the bit mask isolates just the 3rd bit. Since the 3rd bit of the result is 1, we know that the 3rd bit of the original change code was also 1, and the domain spelling changed. In order to extract all the changes from the ChangeCode, we must perform the bit masking operation on all the possible changes. So, your code would look something like this.

if(ChangeCode = 0)

print "No Changes"

if(ChangeCode AND 1 = 1)

print "Syntax Changed"

if(ChangeCode AND 2 = 2)

print "TLD Changed"

if(ChangeCode AND 4 = 4)

print "Domain Spelling Changed"

if(ChangeCode AND 8 = 8)

print "Domain Updated"

Note: The above was just pseudo code. It will not work as is. Bitwise operations are much more complex than what has been presented here. Please do more research on your own if you are interested.