Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 888077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:20:12+00:00 2026-05-15T13:20:12+00:00

is there a python library that would make numbers such as this more human

  • 0

is there a python library that would make numbers such as this more human readable

$187,280,840,422,780

edited: for example iw ant the output of this to be 187 Trillion not just comma separated. So I want output to be trillions, millions, billions etc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:20:12+00:00Added an answer on May 15, 2026 at 1:20 pm

    As I understand it, you only want the ‘most significant’ part. To do so, use floor(log10(abs(n))) to get number of digits and then go from there. Something like this, maybe:

    import math
    
    millnames = ['',' Thousand',' Million',' Billion',' Trillion']
    
    def millify(n):
        n = float(n)
        millidx = max(0,min(len(millnames)-1,
                            int(math.floor(0 if n == 0 else math.log10(abs(n))/3))))
    
        return '{:.0f}{}'.format(n / 10**(3 * millidx), millnames[millidx])
    

    Running the above function for a bunch of different numbers:

    for n in (1.23456789 * 10**r for r in range(-2, 19, 1)):
        print('%20.1f: %20s' % (n,millify(n)))
                     0.0:                    0
                     0.1:                    0
                     1.2:                    1
                    12.3:                   12
                   123.5:                  123
                  1234.6:           1 Thousand
                 12345.7:          12 Thousand
                123456.8:         123 Thousand
               1234567.9:            1 Million
              12345678.9:           12 Million
             123456789.0:          123 Million
            1234567890.0:            1 Billion
           12345678900.0:           12 Billion
          123456789000.0:          123 Billion
         1234567890000.0:           1 Trillion
        12345678900000.0:          12 Trillion
       123456789000000.0:         123 Trillion
      1234567890000000.0:        1235 Trillion
     12345678899999998.0:       12346 Trillion
    123456788999999984.0:      123457 Trillion
    1234567890000000000.0:     1234568 Trillion
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.