Speed of math function atan: comparison D and C++

psychoticRabbit meagain at meagain.com
Tue Mar 6 04:34:08 UTC 2018


On Monday, 5 March 2018 at 06:01:27 UTC, J-S Caux wrote:
>
> So the codes are trivial, simply some check of raw speed:
>
>   double x = 0.0;
>   for (int a = 0; a < 1000000000; ++a) x += atan(1.0/(1.0 + 
> sqrt(1.0 + a)));
>
> for C++ and
>
>   double x = 0.0;
>   for (int a = 0; a < 1_000_000_000; ++a) x += atan(1.0/(1.0 + 
> sqrt(1.0 + a)));
>
> for D. C++ exec takes 40 seconds, D exec takes 68 seconds.

should a be an int?

make it a double ;-)



More information about the Digitalmars-d-learn mailing list