Why do people use long instead of double? (Java)

  • 0

    All the code I saw use long to calculate. Why don't you use double and get a double fraction right away and process that?

  • 0

    a double number holds only 16 valid digits, whereas in our problem, the decimal part can be arbitrarily long. Therefore, you can't rely on double-precision division to give you the accurate solution.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.