I need a macro that takes any expression matching r"-?[0-9]+\Q.\E[0-9]+"
, and encloses it in a BigFloat
constructor. For example, a macro that receives the source code below:
@my_macro function f()
sum = 0.0
x = 902.4
y = -47.1
for i in 1:20
sum += x^2 + 4.3*y
end
return sum
end
and returns the following:
function f()
sum = BigFloat("0.0")
x = BigFloat("902.4")
y = BigFloat("-47.1")
for i in 1:20
sum += x^2 + BigFloat("4.3")*y
end
return sum
end
3 posts - 3 participants