Re:Yet Another Language Speed Test – Counting Primes
by caf on Saturday July 04, 2015 @12:57AM
(#9829277)
The C sqrt function is
double sqrt(double)
Re:Yet Another Language Speed Test – Counting Primes
by x0054 on Saturday July 04, 2015 @01:03AM
(#9829293)
Hmm, I can see that too now, though I am passing into it a CInt, and getting back a CInt. Is it just converting the Int to Double internally and shooting back a Double which is converted to CInt? If so, why do you think it's so much faster?
However, after swapping out the Float only capable square root from Swift Foundation for the C sqrt function, leaving the rest of the code identical, the execution time on the Swift code went down to 35 seconds, basically identical.
I have to wonder if Python, Ruby, and PHP just have a Float only capable square root function, or handle numbers with much higher precision than necessary by the test.