Community
    • Login

    New Python script to add up huge numbers

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 652 Views 2 Watching
    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 Offline
      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 Online
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors