-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another extreme bug #12
Comments
|
Seems like this will be a bug whenever the sum is Found by @Sacha0 |
The bug is in |
is the only issue with this family of expressions? setrounding(Float64, RoundDown) do; prevfloat(Inf) + prevfloat(Inf); end
1.7976931348623157e308
setrounding(Float64, RoundUp) do; nextfloat(-Inf) + nextfloat(-Inf); end
-1.7976931348623157e308
setrounding(Float64, RoundUp) do; nextfloat(-Inf) - prevfloat(Inf); end
-1.7976931348623157e308
# etc |
The problem is with any operation that produces an infinity, e.g. julia 0.6> add_round(prevfloat(Inf), 1e300, RoundDown)
Inf |
why, rounding down, is prevfloat(Inf) + abs(any finite Float64 >
nextfloat(0.0)) not Inf?
…On Fri, Jun 30, 2017 at 1:30 PM, David P. Sanders ***@***.***> wrote:
The problem is with any operation that produces an infinity, e.g.
julia 0.6> add_round(prevfloat(Inf), 1e300, RoundDown)
Inf
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABmqxoG2rStcdKH_nSGHXq2XVrH6sQ4dks5sJTCcgaJpZM4OKgzI>
.
|
Because the result (of adding two intervals) must strictly contain any
possible result.
On 30 Jun 2017 2:14 p.m., "Jeffrey Sarnoff" <[email protected]>
wrote:
… why, rounding down, is prevfloat(Inf) + abs(any finite Float64 >
nextfloat(0.0)) not Inf?
On Fri, Jun 30, 2017 at 1:30 PM, David P. Sanders <
***@***.***>
wrote:
> The problem is with any operation that produces an infinity, e.g.
>
> julia 0.6> add_round(prevfloat(Inf), 1e300, RoundDown)
> Inf
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/JeffreySarnoff/FastRounding.
jl/issues/12#issuecomment-312327184>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABmqxoG2rStcdKH_
nSGHXq2XVrH6sQ4dks5sJTCcgaJpZM4OKgzI>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALtTj0BK4mQuTPvB7k1UomJE7HztPmUks5sJTsigaJpZM4OKgzI>
.
|
More generally, for consistency with the IEEE 754 directed rounding modes? (Inferring behavior from experimentation at the REPL, haven't read the specification itself.) Best! julia> setrounding(Float64, RoundDown)
0
julia> prevfloat(Inf) + 1.0
1.7976931348623157e308
julia> setrounding(Float64, RoundUp)
0
julia> nextfloat(-Inf) - 1.0
-1.7976931348623157e308 |
helpful -- I just want the fix to stay out of the way most of the time |
please confirm that this is the logic you seek @inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:Nearest})::T
!isinf(hi) && return hi
return signbit(hi) ? T(-Inf) : T(Inf)
end
@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:ToZero})::T
!isinf(hi) && return signbit(hi) != signbit(lo) ? AdjacentFloats.next_nearerto_zero(hi) : hi
return signbit(hi) ? nextfloat(T(-Inf)) : prevfloat(T(Inf))
end
@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:FromZero})::T
!isinf(hi) && return signbit(hi) == signbit(lo) ? AdjacentFloats.next_awayfrom_zero(hi) : hi
return signbit(hi) ? T(-Inf) : T(Inf)
end
@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:Up})::T
!isinf(hi) && return (lo<=zero(T) || isnan(lo)) ? hi : next_float(hi)
return signbit(hi) ? nextfloat(T(-Inf)) : T(Inf)
end
@inline function round_errorfree{T<:SysFloat}(hi::T, lo::T, ::RoundingMode{:Down})::T
!isinf(hi) && return (lo>=zero(T) || isnan(lo)) ? hi : prev_float(hi)
return signbit(hi) ? T(-Inf) : prevfloat(T(Inf))
end |
@dpsanders just check that the way infinities are handled matches expectation -- nothing else is altered .. all I am asking is for confirmation that the request and the changes match before introducing this as higher version |
I assume silence is agreement :-> |
I think the new release covers this. |
closing on that basis |
Sorry for the delay in getting to this. Looking good! |
This should give
prevfloat(Inf)
.The text was updated successfully, but these errors were encountered: