I played around with it, and it is pretty feasible to write a fairly capable macro that not only changes floating-point literals, but also handles functions like rand
and ones
, while preserving cases like rand(Float64)
that explicitly specify a precision.
I’ve posted a little (unregistered) package that implements this: https://github.com/stevengj/ChangePrecision.jl
I would appreciate it if people banged on it a bit to see how well it works and whether I missed any important functions. I can register it if it seems useful.
(I don’t recursively handle include
yet, but this would be pretty easy to add if it is needed.)