mlampert commented on a change in pull request #947: Refactor/easing library URL: https://github.com/apache/mynewt-core/pull/947#discussion_r178368672
########## File path: util/easing/src/easing.c ########## @@ -69,125 +69,128 @@ static inline float quadratic_in(float step, float max_steps, float max_val) { float ratio = step / max_steps; - return max_val * pow(ratio, 2); + return max_val * (ratio * ratio); } static inline float quadratic_out(float step, float max_steps, float max_val) { float ratio = step / max_steps; - return -max_val * ratio * (ratio - 2.0); + return -max_val * ratio * (ratio - 2.0f); } static inline float quadratic_io(float step, float max_steps, float max_val) { - float ratio = step / (max_steps / 2.0); + float ratio = step / (max_steps / 2.0f); if (ratio < 1) - return max_val / 2.0 * pow(ratio, 2); + return max_val / 2.0f * (ratio * ratio); - ratio = (step - (max_steps/2.0)) / (max_steps/2.0); - return (max_val / 2.0) - (max_val / 2.0) * ratio * (ratio - 2.0); + ratio = (step - (max_steps/2.0f)) / (max_steps/2.0f); + return (max_val / 2.0f) - (max_val / 2.0f) * ratio * (ratio - 2.0f); } /* Cubic */ static inline float cubic_in(float step, float max_steps, float max_val) { float ratio = step / max_steps; - return max_val * pow(ratio, 3); + return max_val * (ratio * ratio * ratio); Review comment: Understood - but I cannot answer that question without a reference. The interface does not suggest that there is `double` precision involved, it's all based on `float` so as a user that's as much as I can expect. In order to answer the question if this refactoring falsifies the result we would need a definition as to what level of deviation is acceptable. In addition none of the computations uses accumulation which is where `float`'s really start bleeding, all values are monotonically increasing or decreasing and the result is converted to a float. So if the initial value and the result fits into a `float` then every intermediary value will also fit. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services