Xyon (xyon) wrote,
Xyon
xyon

  • Mood:

Enum amusement

Let's say you have a enum like this...
[Flags]
internal enum Amusement
{
    None = 0,
    Alpha = 1,
    Bravo = 2,
    Charlie = 4,
    Delta = 8,
    Echo = 16,
    Foxtrot = 32,
    Golf = 48, // intentional
    Hotel = 64,
    India = 128,
    Juliet = 256
}



... what would you expect the conjugate of Alpha to be?
x       ~x
None    -1
Alpha   -2
Bravo   -3
Charlie -5
Delta   -9
Echo    -17
Foxtrot -33
Golf    -49
Hotel   -65
India   -129
Juliet  -257


It would have been aesthetically pleasing (in one manner) if it was masked to ignore bits not attainable through bitwise or (|) of the elements of the enumeration.; So I was expecting ~Amusement.Alpha to be equivalent to Bravo | Charlie | Delta | Echo | Foxtrot | Hotel | India | Juliet. But the important thing (to me) is that Golf & ~(Delta | Echo) is equal to Foxtrot; which it is.
Tags: code
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments