I am trying to increment a code that uses the setprecision function, but every time I use an example, however simple, it always gives the same error.
when I do:
x = big"1.23456789" setprecision(x, 20)
I get the following error:
ERROR: LoadError: MethodError: no method matching setprecision(::BigFloat, ::Int64)
Closest candidates are:
setprecision(::Type{BigFloat}, ::Integer; base) at mpfr.jl:840
setprecision(::Function, ::Integer; base) at mpfr.jl:969
Stacktrace:
[1] top-level scope
The
setprecisionfunction accepts a type, and globally sets the precision for all operations on this type (there is a variant that does this temporary, but let me focus on a simpler scenario). So what you should do is for example:After
setprecisionall operations onBigFloatvalues will use the precision you set.Note that you should set precision first and only next perform some operation. See an example: