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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You must add the items to your source-collection that is… May 16, 2026 at 4:21 pm
  • Editorial Team
    Editorial Team added an answer The table structure is correct, the best approach would be… May 16, 2026 at 4:21 pm
  • Editorial Team
    Editorial Team added an answer MXML is a way to design and layout a flex… May 16, 2026 at 4:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm playing around with 2 objects {@link http://docs.python.org/library/datetime.html#datetime.date } I would like to calculate
I'm planning to code a library that should be usable by a large number
I'm trying to use a feature of the Microsoft WinHttp library that has been
As my project to do over this summer I would like to create a
I have some small python apps that use cx_Oracle to connect to an Oracle
Ok a short question: Is there any SIMPLE software with a GUI, that lets
I'm still relatively new to Python, so if this is an obvious question, I
Is there a way to program using pure python in Xcode? I want something
Is there an easy way to check whether a phone number entered by the
I am writing a numerical code, in which I would like to use a

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.