• lugal@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    13
    ·
    17 hours ago

    Would this lead to problems if there are multiple identical and close by values? Like for example you have 100 elements each between 1 and 5

    • rbn@sopuli.xyz
      link
      fedilink
      arrow-up
      32
      ·
      15 hours ago

      To reduce the chance of errors, you can multiply all numbers by a factor of 10, 100, 1000, 10000, … for the timeout. The higher the factor, the lower the chances of an incorrect result. And as no one asked about performance…

      • BlueKey@fedia.io
        link
        fedilink
        arrow-up
        2
        ·
        6 hours ago

        Maybe not peak performance but heigh CPU efficency, it’s load ist mostly 0.

      • filcuk@lemmy.zip
        link
        fedilink
        arrow-up
        34
        ·
        15 hours ago

        As added benefit, you can then opyimise the code by dividing the number by 2, making it twice as fast. Think of the savings!