2 ms·
If you can avoid floating point division and search for what squares into the number you're looking at, it may converge more quickly per computer cycle. Heron'
by LanceH 4y ago
If you can avoid floating point division and search for what squares into the number you're looking at, it may converge more quickly per computer cycle.
Heron's method does converge quickly per algorithm cycle, though.
I haven't tried both, but you could definitely do your binary search with only multiplication and bit shifts.
Ok, now I'm looking up number of cycles for division, which is a lot less than I remember. How much has this changed in the last 20 years? any?
Ugh, now I have to try both out tonight. Thanks everyone.
- kadoban 4y agoYeah, my vague sense of low-level stuff these days is that it's moved a lot more towards memory/bus bound, and branch-prediction dependent. Anything that's in a register already and doesn't branch is about the same cost (probably technically extremely wrong, but that's my rule of thumb).