• fsxylo@sh.itjust.works
      link
      fedilink
      arrow-up
      25
      ·
      3 years ago

      Also because if you are dealing with a double, then you’re probably dealing with multiple, or doing math that may produce a double. So returning a double just saves some effort.

    • pomodoro_longbreak@sh.itjust.works
      link
      fedilink
      arrow-up
      7
      ·
      3 years ago

      Yeah it makes sense to me. You can always cast it if you want an int that bad. Hell just wrap the whole function with your own if it means that much to you

      (Not you, but like a hypothetical person)

      • RoyaltyInTraining@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        A double can represent numbers up to ± 1.79769313486231570x10^308, or roughly 18 with 307 zeroes behind it. You can’t fit that into a long, or even 128 bits. Even though rounding huge doubles is pointless, since only the first dozen digits or so are saved, using any kind of Integer would lead to inconsistencies, and thus potentially bugs.

    • karlthemailman@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      How does that work? Is it just because double uses more bits? I’d imagine for the same number of bits, you can store more ints than doubles (assuming you want the ints to be exact values).