[Novalug] [OT] Question for computer scientist

James Ewing Cottrell 3rd JECottrell3@Comcast.NET
Mon Feb 2 18:37:29 EST 2009


As Greg mentioned, powers of 2 are trivial: just a shift count. But to 
answer your question in the general case, say, 3, should be obvious: a 
lookup table is generally faster than actual multiplication, and 
especially division.

In any case, using left shift for multiplication and right shift for 
division should be a big win. Avoiding floating point under any 
circumstances is even better.

JIM

Bonnie Dalzell wrote:
> If you have a value you are using a lot in a program - in this case 
> powers of 2 (2^n and 1/2 to the n). Is it easier on the system (or 
> faster) to compute them when you need them or fetch them from a 
> premade look up table?
> 
> I ask this because I am working on a program to compute coefficients of 
> inbreeding and the closed source compiled dos program I have been using 
> seems to have a look up table file that it uses in relation to coi and I 
> think - examining the table in a hex editor that it is powers of two 
> precalculated.
> 
> I do not have access to the source code for the old dos program. but i 
> have been running it to check and see if the calcs of the value 
> generated by my program are correct.
> 
> No one seems to have published a numerical recipe for calculating 
> coefficient of inbreeding anyplace i can find via google so I (a 
> non-mathematician) am trying to come up with one.
> 
> I have also decided if I get one (numerical recipe) that works it is going 
> onto the web as is the program. Since the program is in perl it is by 
> defiition open source.
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                         Bonnie Dalzell, MA
> mail:5100 Hydes Rd PO Box 60, Hydes,MD,USA 21082-0060|EMAIL:bdalzell@qis.net
> 
> freelance anatomist, vertebrate paleontologist, writer, illustrator, dog
> breeder, computer nerd & iconoclast... Borzoi info at www.borzois.com.
> Editor Net.Pet Online Animal Magazine  - http://www.netpetmagazine.com
> HOME http://www.qis.net/~borzoi/          BUSINESS http://www.batw.com
> _______________________________________________
> Novalug mailing list
> Novalug@calypso.tux.org
> http://calypso.tux.org/cgi-bin/mailman/listinfo/novalug
> 
> 
> ------------------------------------------------------------------------
> 
> 
> Internal Virus Database is out of date.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.176 / Virus Database: 270.10.14/1917 - Release Date: 1/26/2009 6:37 PM
> 




More information about the Novalug mailing list