better allocations will help. use prefix not postfix. might not matter for ints but does for class types. some of your algorithms could be improved but you would have to dig down into knuth(TAOCP) for details or maybe check GMP's docs. I think they have a section annotating the used algorithms.You can really get a speed increase especially on p4 machines by going the asm route.there is plenty of details on how to do this in the link i posted earlier but obviously you will need to know asm to do that.