-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fld1 is weird #28973
Comments
We could just get rid of it? |
alternatively, we could make it only defined for integer values (it is somewhat non-sensical for floating point). |
|
In calendar calculations,
|
Just ran into this: julia> fld1(0.4, 0.9)
1.0
julia> fld1(0.41, 0.9)
1.0
julia> fld1(0.401, 0.9)
1.0
julia> fld1(0.4001, 0.9)
1.0
julia> fld1(0.40001, 0.9)
0.0 That's definitely not what I expected. |
😢
I am preparing a PR |
It seems that would also fix the example in the OP: julia> Base.fld1(x::T, y::T) where {T<:Real} = (m = mod1(x, y); fld((x - m) + y, y))
julia> fld1(0.09, 0.1)
1.0
julia> fld1(0.08, 0.1)
1.0
julia> fld1(0.07, 0.1)
1.0
julia> fld1(0.06, 0.1)
1.0 |
* bugfix: fld1 order of ops fixes #28973
Hi.
I necro-posted this as a comment in a different issue ( #14487 ), which is open since 2015 and thus probably won't get looked at any time soon. So here goes. I was playing around with
fld1
on Julia 1.0 on a Ubuntu system, delved too deep and awoke something in Khazad-dum.fld
andcld
work as expected:and
However:
WAT.
My system:
Can anyone else reproduce this, or is this a problem uniquely on my system? I could easily live without
fld1
, but this result ... makes me nervous.The text was updated successfully, but these errors were encountered: