This package allows you to effectively change the “default” precision in a large body of Julia code, simply by doing e.g.
@changeprecision Float32 include("foo.jl") or, for example:
using ChangePrecision @changeprecision BigFloat begin x = pi/2 y = 2.1 * x * rand(3,3) \ linspace(0,1,3) end
and all floating-point literals, as well as many functions like
rand() or expressions like
3/2 will now default to the new type (here
BigFloat) rather than
Float64. Code that uses explicit types, like
rand(Float64), will not be affected.
This is mainly meant for informal user “scripts” rather than library code, since library code should typically be written in a type-generic manner (inferring the desired precision from function arguments rather than hardcoding it).