Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/16/01 23:06
Read: times


 
#17711 - RE: Multiplication 2 bytes by 0.034146
"...multiply a 9 bit number by 0.034146 and keep only the integer portion of it. "

That's even easier...

Work the problem backwards: You have only 18 possible answers {0...17}

If you use a spreadsheet to precompute the answers for all input numbers {0...512} them you'll only need to know the numbers where the answer CHANGES from the previous sequential input number. Then all you need do is a range limit table. For 18 answers, you could do a binary tree and get the result from the table in 5 comparisons.

The table would be 18 records of 2 filds. Field one would be the comparison byte. This would be contain one of eighteen subset members from the set {0...512}. The next field would be the answer field (This can be inferred directly from the record number {0..17}.

Now you take a input number from the set {0...512} (yeah 512-1 if you care to avoid the chirpy posts) and use a binary search on the 18 records so see which record it is bound by. Once you find a record with a comparison byte larger than you input byte, you have your answer inferred by the record number {0...17} = answer mapping {0...17}.

Actually, with the spreadsheet you can determine if any loss is created by taking the input byte, dividing it by 2 to make it a 8 bit byte size and therefore more convenient for the table; instead of atable of 9 bit words, you could use 8 bit bytes. That is more conducive to binary search algorihms around the movc a,@a+dptr instruction.

I'll leave that search algorithm to you. I use a mapped data structure that hs inferred pointers through a clever formula on the index pointer.


List of 16 messages in thread
TopicAuthorDate
Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication - Lance            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      
RE: Multiplication 2 bytes by 0.034146            01/01/70 00:00      

Back to Subject List