Re: [julia-users] display precision
El domingo, 15 de noviembre de 2015, 12:45:11 (UTC-6), Yichao Yu escribió: > > On Sun, Nov 15, 2015 at 1:25 PM, digxx > > wrote: > > Is it possible to display the precision of a number to arbitrary > decimals > > points? > > For example if I want to display pi (or any other result) up to 1e6 > > decimals?! > > Note that the BigFloat precision is given in binary digits, not decimal digits, so you have to multiply the 10^6 that you want by log2(10) = 3.32...: num_binary_digits = ceil(Int, 10^6 * log2(10)) set_bigfloat_precision(num_binary_digits) @time s = string(big(pi)) length(s) The results are 103 digits and 0.184317 seconds Of course, actually *displaying* the string takes a lot longer (output is slow).
Re: [julia-users] display precision
On Sun, Nov 15, 2015 at 1:25 PM, digxx wrote: > Is it possible to display the precision of a number to arbitrary decimals > points? > For example if I want to display pi (or any other result) up to 1e6 > decimals?! For arbitrary result, you can't print arbitrary precision if your calculation does not have that precision (unless you just want to see 1e6 zeros printed). You want to perform the calculation on BigFloat[1] if you need that precision (and then printing it out should give you the expected number of digits). In theory, there could be a way to print out pi to a high precision without converting it to a BigFloat first although I also don't see why that's a useful thing to do in general. [1] http://julia.readthedocs.org/en/latest/manual/integers-and-floating-point-numbers/#arbitrary-precision-arithmetic
[julia-users] display precision
Is it possible to display the precision of a number to arbitrary decimals points? For example if I want to display pi (or any other result) up to 1e6 decimals?!