Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Algorithm, How to Design 1

Status
Not open for further replies.

DummyForAccess

Technical User
Aug 7, 2002
38
0
0
US
Argh, Long ago in a past lifetime I worked with someone who used an algorithm to store "true" values while looping through error-checking code. At the end of looping through each record, a total number for that record identified which errors the record had. If I remember right, we used a table that had numbers that added up, and I think they were something like prime (?) numbers? --if you used 1,2,3 etc it wouldn't work, they wouldn't add up to numbers that would tie back to the individual errors. Can anyone offer assistance, at least tell me what numbers would make sense and where I could get them? This was such a practical way to create code and efficient way to design the whole thing. Any help will be appreciated. Thanks!!
 
Maybe that person used individual bits of an large integer to represent a specific error in a record ?
That's an economic way to do it.
The values would then be 1, 2, 4, 8, 16 ..... and (surprise) you could store 32 different errors in a 32 bit integer.
/JOlesen
 
No, the 1,2,4 type numbers don't work. If I remember, the numbers were something like 1, 3, 5.. You have to be able to add them as you loop thru code. So if you used 1, 3 5 as an example, if 1 and 3 are added to a variable then the variable is 4. But by seeing that the variable is 4 you can tell that 1 and 3 are true. Or if the variable gets set to 9, you know that 1, 3 and 5 are true. Does that make sense? I just don't know how to figure out what the numbers are....
 
Oh, it still could make sense if the lowest bit was used to indicate something special - for instance an error.
If set (=1) an Error was found, if not set no error was found.
The remaining bits could be used to indicate other things worth saying about the record - like a kind of checkmarks :
Bit31 : Social Security ID was found / Not found.
Bit30 : Address was found / Not found
Bit29 : Name was found / Not found
etc. etc.

If for instance Name is a mandatory field and is missing in a record, the low bit would be set to indicate an error, and bit29 would be set / cleared to indicate that Name was missing.
This is a quite normal programming technique in 'C', and can be done in a lot of variants - very useful indeed.
/JOlesen
 
Interjecting...

Since this is the OO group, why not consider building an OO solution to the problem?

Nick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top