rounding decimals

Viewing 2 reply threads
  • Author
    Posts
  • December 16, 2020 at 3:12 PM #42874

    Eric de Mildt
    Participant

    Am I right in finding that 0.5 is occasionally rounded down instead of up? Is it that rounding decimal places in Javascript can go “quirky”? And can it be solved in TF calculation fields?
    What would be the best approach?
    Thanks for any advise.

    Eric

    December 16, 2020 at 10:49 PM #42877

    Sam Moffatt
    Participant

    I’ve not personally noticed the rounding behaviour but it sounds to me like an implementation of IEEE 754’s rounding rules for round half to even which is a strategy for mitigating rounding bias.

    You might be able to use a script field to have Javascript do the rounding for you, I believe it uses the round up strategy.

    December 17, 2020 at 9:39 AM #42883

    Eric de Mildt
    Participant

    Hi Sam,

    Thanks for your reply and pointing this out!
    Field script does the trick, rounds up from 0,5.
    So it works!
    I’m anything but a programmer, didn’t know about these rounding rules (Rounding is no a straightforward subject though once you start reading on the subject ;-) But interesting ).

    Cheers
    Eric

Viewing 2 reply threads

You must be logged in to reply to this topic.