>>>>>>>>If I store a number of power of 2 into INT field, how many different "values" will this field hold? I am not sure I phrase my question correctly, so here is an example of what I am trying to say.
>>>>>>>>Say I store 128 into a INT field. Which means that I can get 7 numbers: 2, 4, 8, 16, 32, 64, 128
>>>>>>>>Since an INT field can hold up to 2,147,483,647, what is the max number can I get from this value?
>>>>>>>
>>>>>>>The maximum value in regards to that calculation would be 1,073,741,824. That would be 2^30. If you go higher, you will be one number over the maximum. I would suggest to switch the field to Big Integer if you have some concerns.
>>>>>>
>>>>>>This is about 1 billion. For what I am trying to do, this is more than enough. Thank you.
>>>>>
>>>>>
>>>>>Still somewhat puzzled by your question ;-)
>>>>>
>>>>>One possible use for a int in power2 is in "combination mode" as array of bit fields most of us remember.
>>>>>Yes, you can easily squeeze 30 flags into an INT, but why ? SQL server has the bit data type and will pack on byte sizes depending on the number of flag[s / columns] you need. Say you need 15 flags, SQL Server will only reserve 2 bytes. Small benefit size ways but NO DANGER if suddelny you need 33 flags....
>>>>>
>>>>>OTOH, if there the max value which is important after differing # of iterations, I'd save the exponents and work directly with them, perhaps with dedicated functions or SPs.
>>>>>
>>>>>Indexing on such fields probably problematic IAC. What am I missing ?
>>>>>
>>>>>Friday curios
>>>>>
>>>>>thomas
>>>>
>>>>I don't understand how the bit data type can serve me in this case (and this is just me). Let me describe what I am considering this field (INT) for (simplified example).
>>>>Say, the program has 5 features: Feature 1, Feature 2, Feature 3, Feature 4, Feature 5. Each record is using none, or any number of features. So I will store in the INT field (in pseudo code) the following value:
>>>>
>>>>REPLACE MyFeatureField with iif( UsingFeature1, 1, 0) + iif( UsingFeature2, 2, 0) + iif( UsingFeature3, 4, 0) + ;
>>>> iif( UsingFeature4, 8, 0) + iif( UsingFeature5, 16, 0)
>>>>
>>>>Then the code (using syntax " MyFeatureField & > 1 ") can check if the record is "flagged" for Feature1 or 2 or whatever. The number of "Features" is very large; hence I was asking the question.
>>>>How would I apply your suggestion of a BIT type?
>>>
>>>Google hint:
>>>sql server bit field type
>>>Each Usingfeature? would be a separate bit column
>>>
>>>AFAIR before vfp9 Bit is the easiest field to map to vfp logical in cusor/view Remote Connections, but used vfp8 only a short time.
>>>Portability to other backends is not really something you strive for, otherwise I'd either use smallest int with 1/0 logic (or empty() if you prefer) or the power trick you already use.
>>
>>I had a chance to get away from computer and clear my head. Now that I re-read your message I understand what you are suggesting. But in my case, since I need about 300 flags, I would have to create 300 bit columns. And I don't like this idea. I will consider other options. Thank you.
>
>You could make a Character(30) field with each position representing a Feature. Then you can check the Feature with substr(Features,1,1) = "Y", Substr(Features,2,1) = "Y" etc.
This is exactly how this feature works in my app now. And I want to change it; no urgent need but I feel it should be improved.
Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham