-
Notifications
You must be signed in to change notification settings - Fork 87
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
ceil
and floor
are dangerous
#432
Comments
|
For the sake of generic programming, we probably should not remove auto foo(auto v) { return ceil(v); } and the above will work with arithmetic types, chrono::durations, units::quantity, and possibly other types as well. |
We can consider adding unit-aware alternatives as we did for Option Aceil_in(metre, q); This is consistent with Option Bceil_in<metre>(q); This is probably more readable but inconsistent with |
I like Option A, partially because it's what we use in Au. 🙂 Here are some representative test cases to show example usages: The main difference is that we spell it I also think it's valuable to be consistent with |
I don't really buy that argument. I think the fact that it works with It's meaningful to |
Also, to comment directly on the original issue post: yes, exactly! And we have real world implementation experience that validates this approach (i.e., to provide |
@chiphogg, thanks for the valuable feedback!
Well, I was waiting for someone to say that 😉 It was just some rough idea of why it might be useful, but I also do not see a use case for that. I will change that in V2 soon. |
The one similar |
Done in V2. |
What's the ceiling of my height? Much like
log
,ceil
andfloor
don't make sense for strongly-united types. I could seeceil_in<unit>
, but justceil
andfloor
aren't invariant against changes in the unit used.I think these are the similar ones:
ceil
floor
round
trunc
I guess they are all transcendental?
The text was updated successfully, but these errors were encountered: