BigFloat type

Hello,
I have a variable of this type:


and I would like tto ransform the format Float64 to BigFloat. How do that ?

The following command doesn’t work :
BigFloat.(MyVar)
convert(BigFloat,MyVar)

May be defining the BigFloat as default format ? (I am not found this way)

big.(MyVar), maybe?

In general, if you want to use BigFloat, then you should change the inputs to your function, e.g. pass a BigFloat for the input when you call ForwardDiff.jl (which is what I presume you are using). If you don’t use BigFloat all the way through, you will generally be limited by the accuracy of the least-precise step of the computation.

The ideal is to write your functions so that they always compute in the precision of their inputs, so that you can pass in whatever precision you want (Float64, Float32, BigFloat) later and they will do the right thing. This takes a little practice to do properly, with the help of Julia’s type-promotion and introspection machinery, but if you post a specific example of a short function people can give you some tips on how to make it precision-generic.

PS. Don’t post screenshots of code. Post quoted code, and post minimal runnable snippets to make it easier for other people to help you. Read Please read: make it easier to help you

2 Likes

Thank you, using as input a BigFloat instead of Float format works.