Hacker News new | ask | show | jobs
by ColinWright 886 days ago
> ... the "unoptimised" version is consistently between 4 and 5 times faster than the hand-optimised variants:

I'm getting this comment a lot, but so far the reason has been that people are using smallish numbers, and implementing the square root in floats.

In the context where this exploration is taking place, you can't do that. We're working with exact huge integers, and while a square root on floats can get you in the ballpark, you then need to refine the answer to get the exact value, and that takes order of magnitude the same time.

1 comments

How big are we talking? The benchmarks I tried the two numbers in your example, but yes, if you go above 2^53, then you will run into trouble with the naive solution, but that is for correctness reasons, not performance reasons.
This is an experiment on aspects of a factoring algorithm ... we're going to be talking about a few hundred digits base 10.

So up to around 10^200 or so, which is around 2^600.

Well yes, that definitely changes the game!!