-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
While I was reviewing the PR #123, I found a minor bug.
julia> float(3N3f5) # this is ok
3.0f0
julia> float(3N4f12)
3.0000002f0
julia> float(3N8f8)
3.0000002f0
julia> float(3N10f6)
3.0000002f0
julia> float(3N12f4)
3.0000002f0
julia> float(3N13f3)
3.0000002f0
julia> float(3N2f6)
3.0000002f0
julia> float(3N4f4)
3.0000002f0
julia> float(3N5f3)
3.0000002f0
I think this is a problem with the division optimization.
FixedPointNumbers.jl/src/normed.jl
Lines 75 to 78 in da39318
function (::Type{T})(x::Normed) where {T <: AbstractFloat} | |
y = reinterpret(x)*(one(rawtype(x))/convert(T, rawone(x))) | |
convert(T, y) # needed for types like Float16 which promote arithmetic to Float32 | |
end |
The rounding errors can occur everywhere, but especially the errors at integer values are critical.
julia> isinteger(float(3N5f3))
false
johnnychen94
Metadata
Metadata
Assignees
Labels
No labels