-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
floats and range #2
Comments
Ops, looked at this but forgot to respond. Isn't this just quirk of floating point numbers. Not really much this lib can do about that. |
Is it possible to: not provide And the related proposal: make |
Not sure what you mean. Do you mean that
I made it exclusive as it follows how slicing works in zig, so zig programmers are familiar with it. |
Yes.
Ok. What about new |
I see. Yea, both of these sounds good to be 👍 |
Or to add new parameter to range_ex: |
Hmmmmm. How about: pub fn range(comptime T: type, start: T, end: T, opts: struct { inclusive: bool = false, step: T = 1 }) Range(T) {
return .{ .start = start, .end = end + (opt.step * @boolToInt(opt.inclusive)), .step = opt.step };
}
...
range(u8, 0, 6, .{});
range(u8, 0, 6, .{ .step = 2 }); Basically, having and options argument with all fields having default values. |
Looks good! 👍
What will happen for |
Well, that would overflow with the current behavior. We could have an implementation that handles this, which might be nice, but it probably has a cost. |
As of 0c2a668, ziter.range(u8, 0, 10)
.step_by(2) |
test "f32, 0, 1, 0.1"... result = 4.5e+00
//correcttest "f32, 0, 1, 0.3"... result = 1.80000007e+00
//incorrectThe text was updated successfully, but these errors were encountered: