03-16-2003, 06:14 PM
Hmm, true, the division might not be the best, but many times, I would say it is probably still faster then all the work needed to build a table. Although I must admit my timing knowledge, especially in recent processors, is limited.
And yes, you must know in advance :) That is perhaps the biggest thing though. "My" method (I did not invent it, don't remember were I read it though), has the advantage that one do not need to actually "save" the info somewere. One can for example calculate the probabiloity on the fly so to speak. One can also stream unknown info (well, of known format) without having to save it and so on.
I have to test that divsion thing some day to see how much "time" and thus code one can have and still be faster than it. There is less shuffling of data for sure when one don't need to build a table for example.
By the way, my post was not primarilly for you (I had a faint idea I discussed it with you but was not sure), but just in general. I personally like the method, especially when one isn't in a time critical situation since it is much "simpler" than to have to build a table, and I don't like the "loop until it works" solution.
Thanks for the comments though.
And yes, you must know in advance :) That is perhaps the biggest thing though. "My" method (I did not invent it, don't remember were I read it though), has the advantage that one do not need to actually "save" the info somewere. One can for example calculate the probabiloity on the fly so to speak. One can also stream unknown info (well, of known format) without having to save it and so on.
I have to test that divsion thing some day to see how much "time" and thus code one can have and still be faster than it. There is less shuffling of data for sure when one don't need to build a table for example.
By the way, my post was not primarilly for you (I had a faint idea I discussed it with you but was not sure), but just in general. I personally like the method, especially when one isn't in a time critical situation since it is much "simpler" than to have to build a table, and I don't like the "loop until it works" solution.
Thanks for the comments though.
There are three types of people in the world. Those who can count and those who can't.