Skip to content

Ceil / Floor?

badstrrefbadstrref Member Posts: 124
edited January 2018 in Builders - Scripting
- please delete -

Comments

  • SherincallSherincall Member Posts: 387
    edited January 2018
    I'm guessing something like this:
    int ceil(float f)  { return (f - IntToFloat(FloatToInt(f))) > 0.0 ? FloatToInt(f) + 1 : FloatToInt(f); }
    int floor(float f) { return (f - IntToFloat(FloatToInt(f))) >= 0.0 ? FloatToInt(f) : FloatToInt(f) - 1; }
    If you care about perf, cache the result of FloatToInt(f) in a variable.
    Post edited by Sherincall on
  • badstrrefbadstrref Member Posts: 124
    Thanks
Sign In or Register to comment.