See here for function specific absolute and relative errors over 0:1 and 1:2.
- Current — most recently tagged version of the documentation.
The package can be installed with Pkg3
or Pkg.add
.
pkg> add DoubleFloats
julia> using Pkg
julia> Pkg.add("DoubleFloats")
julia> using DoubleFloats
julia> d64 = sqrt(Double64(2)); 1 - d64 * inv(d64)
0.0
julia> d32 = sqrt(Double32(2)); 1 - d32 * inv(d32)
0.0
julia> d16 = sqrt(Double16(2)); 1 - d16 * inv(d16)
0.0
julia> typeof(ans) === Double16
true
julia> using DoubleFloats
julia> x = sqrt(Double64(2)) / sqrt(Double64(6))
5.7735026918962576450914878050194151e-01
julia> string(x)
"5.7735026918962576450914878050194151e-01"
julia> showtyped(x)
Double64(0.5773502691896257, 3.3450280739356326e-17)
julia> showtyped(parse(Double64, stringtyped(x)))
Double64(0.5773502691896257, 3.3450280739356326e-17)
julia> Meta.parse(stringtyped(x))
:(Double64(0.5773502691896257, 3.3450280739356326e-17))
julia> using DoubleFloats
julia> ϕ = Double32(MathConstants.golden)
1.61803398874989490
julia> phi = "1.61803398874989484820+"
julia> ϕ⁻¹ = inv(ϕ)
6.18033988749894902e-01
julia> ϕ == 1 + ϕ⁻¹
true
julia> ϕ === ϕ * ϕ⁻¹ + ϕ⁻¹
true
typed value | computed value | ~abs(golden - computed) |
---|---|---|
MathConstants.golden |
1.61803_39887_49894_84820_45868+ | 0.0 |
Float64(MathConstants.golden) |
1.61803_39887_49895 | 1.5e-16 |
Double32(MathConstants.golden) |
1.61803_39887_49894_90 | 5.2e-17 |
op | speedup |
---|---|
+ | 11x |
* | 18x |
\ | 7x |
trig | 3x-6x |
- results from testing with BenchmarkTools on one machine
- BigFloat precision was set to 106 bits, for fair comparison
If your input values are Float64[Float32], map them to Double64[Double32] and proceed with your computation. Then map the output values to Float64[Float32], and work with those values. Where throughput is important, this manner of us can be applied to particularly sensitive parts of your computation.
Usage questions can be posted on the Julia Discourse forum. Use the topic Numerics
(a "Discipline") and a put the package name, DoubleFloats, in your question ("topic").
Contributions are very welcome, as are feature requests and suggestions. Please open an issue if you encounter any problems. The contributing page has a few guidelines that should be followed when opening pull requests.