> ...when you have a value eg 22 which is made up of 2+4+16 > so you know of > all your options valued 2,4,8,16,32 Etc only 2 and 4 and > 16 apply.
> I know there must be a mathematical name for this, but > what? > Does anyone have some example CF code to 'decrypt' such > numbers? > Are there other [simple] ways to do this to handle a large > number of > options (>25, so I don't start having giant numbers?) > Something to do > with prime numbers perhaps? > You can tell I'm not a mathmatician can't you! > THANKS! If you really want something like this (I generally don't), I would look into using bitmaskread and bitmaskset... Start with 0 ... this gives you an integer which will have (iirc) 32 registers for placing a bit... so you can turn any individual bit on or off like so: <cfset options = 0> <!-- turn on the option in the first bit ---> <cfset options = bitMaskSet(options,1,0)> Then to read that option: <cfset option1 = bitMaskRead(options,0)> ... the bitmask functions allow you to manipulate more than one bit at a time, but this is probably the easiest way to handle it. I generally avoid using these for a host of reasons, not the least of which being that it becomes very difficult to do anything with the value within a query in a relational database where I would be storing the value of "option". So instead I generally store individual columns of type integer or number(1,0). p.s. I recognize the pattern you were asking for (which is different than this bitmask solution)... in grade school I remember having to use those values to assign display properties in GW Basic, among other things. At the time they were dealing with extremely limited hardware (physical ram). Imo nowadays it's always more trouble than it's worth. s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.sys-con.com/story/?storyid=44477&DE=1 http://www.sys-con.com/story/?storyid=45569&DE=1 http://www.fusiontap.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF community. http://www.houseoffusion.com/banners/view.cfm?bannerid=34 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182266 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

