3 ms·
I ran the following in my Julia REPL julia> @time BigFloat(π, precision=20000000); 11.208211 seconds (60.53 k allocations: 2.932 GiB, 0.16% gc time) Which is
by SherlockSage 4y ago
I ran the following in my Julia REPL
julia> @time BigFloat(π, precision=20000000);
11.208211 seconds (60.53 k allocations: 2.932 GiB, 0.16% gc time)
Which is pretty good considering I ran this in WSL on my laptop and Mathematica in a different comment took 10 seconds. (Plain Windows took ~26 seconds for some reason?)
- rnestler 4y ago> (Plain Windows took ~26 seconds for some reason?) Maybe the allocations were the reason?
- Someone 4y agoI’m too late to update my own comment, but I now suspect BigFloat(π, precision=20000000) may allocate a Bigfloat with precision of two million digits and then store the constant π which has much lower precision in it. What value does that print?
- juliusgeo 4y agoIt definitely does calculate it otherwise it would diverge significantly at lower digits from the Gauss Legendre and Chudnovsky algorithm that I compared it to. It just defers calculation to MPFR, the C library Julia binds to for BigFloat calculations.
- juliusgeo 4y agoAlso one additional comment is that you are setting precision in number of bits, not in decimal digits. It obviously runs much faster when it is only computing log2(20000000) not 20000000 digits of precision.