Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • round(0.5) == 0, round(1.5) == 2, round(2.5) == 2

  • https://stackoverflow.com/questions/33019698/how-to-properly-round-up-half-float-numbers < Proper way to solve this in python

    Code Block
    languagepy
    # Mirko's Disgusting hack for intuitive rounding (0.5 -> 1)
    # Don't use this (i do) (assumes positive numbers only, also that you dont care about small decimal points)
    def rounder(number, ndigits=None):
        # Just tip the scales towards positive lol
        return round(number + 1e-8, ndigits)