JuliaMath / JuliaMath/Decimals.jl
Proposal for @decimal macro
- Dominant language
- Julia
- Stars
- 62
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
Would the following macros be useful?
```julia
julia> macro decimal(ex)
trans!(e::Real) = :(Decimal($e))
trans!(e::Expr) = begin
for (i,a) in enumerate(e.args)
a isa Integer && continue
a isa Real && (e.args[i] = Decimal(a))
a isa Expr && trans!(a)
end
ex
end
:(number($(trans!(ex))))
end
@decimal (macro with 1 method)
julia> 100 * 1.1576
115.75999999999999
julia> @decimal 100 * 1.1576
115.76
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.