-
-
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
Sequences aren’t computed properly #24357
Comments
I believe this is expected. Use |
If you search the Julia history, you'd find that floating point ranges have been heavily discussed and (re-)adjusted over the years. If you search the Python history you can also find some lengthy discussions of the topic. Our current implementation assumes that the inputs are relatively-small-denominator rationals. This assumption produces julia> length(0.1:0.1:0.3)
3 which most people prefer despite the fact that julia> 3*0.1 <= 0.3
false Personally, I think that this is too magic and too different from how floating point math normally works and I'd prefer a solution similar the one suggested by @pablosanjose (although I think it should be |
This is not an accurate description of what it does, but I'm rather tired of explaining this. |
I cannnot understand this at all. Do you have a link for me / would you include some description in And would it maybe be useful, outputting a warning, if the used step differs from the specified one? Otherwise this can lead to errors, the users aren’t aware of. |
Long story short, julia> 2π < 100*(2π/100)
true
julia> 2π / (2π/100)
99.99999999999999 Julia is actually taking your requested values completely literally – they just aren't what you imagine them to be. @andreasnoack is scapegoating rational lifting (again), whereas that lifting is NOT happening here, so it cannot be at fault: julia> collect(0:2π/100:2π) == [(2π/100)*k for k = 0:99]
true Y'all are just mad at floating-point arithmetic. |
I want to generate substeps of
0:2π
, but if I set the stepping to2π/100
, I get wrong results.This works well with 98/99/101/102 steps, but not with 25/50/200… O_o
I run julia 0.6.1 with everything up to date.
The text was updated successfully, but these errors were encountered: