23 lines
453 B
Julia
Executable file
23 lines
453 B
Julia
Executable file
#!/usr/bin/env julia
|
|
|
|
# Jacek Poziemski 272389
|
|
|
|
"""
|
|
kahanmacheps(T)
|
|
|
|
Calculate the Kahan machine epsilon
|
|
using the following expression: `3(4/3 - 1) - 1`.
|
|
|
|
# Arguments
|
|
- `T`: a floating point number type <: AbstractFloat
|
|
"""
|
|
function kahanmacheps(T)
|
|
return T(3) * ((T(4) / T(3)) - one(T)) - one(T)
|
|
end
|
|
|
|
for T in [Float16, Float32, Float64]
|
|
println("kahanmacheps($T): $(kahanmacheps(T))")
|
|
println("eps($T): $(eps(T))")
|
|
|
|
println()
|
|
end
|