ok guys 'n' gals,
i'm working on a routine to take a database 'flag' which is basically a sum (to the power of 2 - i.e. bitwise operations) of an enumeration that is defined in my app and used the same way in the SQL. I've worked out a pretty neat routine (which i've demo'd in the link below) which will tell me what enum values 'compose' my final number. I'll describe this below to give a flavour:
if my final value in the 'flag' is:
23 - my enum values are 1,2,4,16 (i.e. those add up to 23)
49 - 1,16,32
153 - 1,8,16,128
260 - 4, 256
etc, etc...
All is great, however, i can't help but feel that my method could be a bit more 'streamlined' and capable of doing a bit of reflection (to figure out the min/max of the enum) to make things a bit more generic. to this end, i invite you folks to dissect and reassemble my code to fulfil the brief above.
happy headaches all :D
www.originaltalent.com/downloads/bitwise.zip
jimi
http://www.originaltalent.com