Community
    • Login

    New Python script to add up huge numbers

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 354 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • AlloyCoderA
      AlloyCoder
      last edited by PeterJones

      I created a Python script for adding up very large numbers in a selection:

      https://github.com/AlloyCoder/AddUpSelected

      It properly handles a ton of edge cases - dollar signs, commas as thousands-separators, and lots of neutral characters are stripped away. Anything that makes a number ambiguous will cause it to be ignored.

      It currently defaults to a maximum of 60 decimal digits, this is arbitrary and can be changed in the code with a single constant.
      The code is certainly not pretty; but just for fun I optimized the heck out of its performance, it even has some optional performance timers.
      I hope it might be useful to some as an example for performant Notepad++ Python code. I welcome any comments and suggestions.

      PeterJonesP 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @AlloyCoder
        last edited by

        @AlloyCoder ,

        https://github.com/AlloyCoder/AddUpSelected

        Seemed to work for me (though I didn’t try with enough numbers to notice performance).

        Intentionally ignoring scientific notation is a bummer.

        AlloyCoderA 1 Reply Last reply Reply Quote 1
        • AlloyCoderA
          AlloyCoder @PeterJones
          last edited by

          @PeterJones OK, I’ve added the ability to digest scientific notation, and increased the default accuracy to 200 digits.
          Version 1.08 is up on github: https://github.com/AlloyCoder/AddUpSelected

          1 Reply Last reply Reply Quote 3
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors