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 3854772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:40:27+00:00 2026-05-19T17:40:27+00:00

My reputation appears as 2,606 . If I had more, it would look like

  • 0

My reputation appears as 2,606.

  • If I had more, it would look like 15.4k.
  • If I had a lot more, it would look like 264k

What’s the best way to display a number in this format using Ruby?

  • 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-19T17:40:27+00:00Added an answer on May 19, 2026 at 5:40 pm

    You can do with this simple method:

    class Integer
      def pretty_str
        case
        when self < 1000
          to_s
        when self < 10000
          to_s.insert(1, ",")
        when self < 100000
          ("%.1fk" % (self / 1000.0)).sub(".0", "")
        else
          (self / 1000).pretty_str << "k"
        end
      end
    end
    
    123.pretty_str       #=> "123"
    1234.pretty_str      #=> "1,234"
    12345.pretty_str     #=> "12.3k"
    123456.pretty_str    #=> "123k"
    1234567.pretty_str   #=> "1.234k"
    12345678.pretty_str  #=> "12.3kk"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had this discussion with a high reputation PHP guy: PDO has no use
I would like to check if a digit appears a set amount of times
Much like the Stackoverlow reputation rounding, I'm hoping to do the same thing with
I'm looking to implement a reputation-based point system for a QA site. I like
This is the code: struct comp { bool operator()(Reputation *one, Reputation *two) { if
I have written an ASP.NET web service. It looks like this: WebServices.logic pLogic =
i've plan for my Rails Apps where user could have reputation like good/bad user.
in this screencast Ryan Bates showed how to implement reputation system from scratch. But
VB6 had a reputation for being too forgiving (and thereby allowing bad practices) and
Because of my noob reputation, I cannot reply to this Thread , in specific

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.