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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:52:44+00:00 2026-05-21T06:52:44+00:00

Is there a way to use String.Format to convert numbers to number/character representations. For

  • 0

Is there a way to use String.Format to convert numbers to number/character representations.

For example

2400 -> 2.4k
2,600,000 -> 2.6m
  • 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-21T06:52:45+00:00Added an answer on May 21, 2026 at 6:52 am

    I am providing a sample code. Please try to make it in your way

    private static string ToEngineeringNotation(this double d)
        {
            double exponent = Math.Log10(Math.Abs(d));
            if (Math.Abs(d) >= 1)
            {
                switch ((int)Math.Floor(exponent))
                {
                    case 0: case 1: case 2:
                        return d.ToString();
                    case 3: case 4: case 5:
                        return (d / 1e3).ToString() + "k";
                    case 6: case 7: case 8:
                        return (d / 1e6).ToString() + "M";
                    case 9: case 10: case 11:
                        return (d / 1e9).ToString() + "G";
                    case 12: case 13: case 14:
                        return (d / 1e12).ToString() + "T";
                    case 15: case 16: case 17:
                        return (d / 1e15).ToString() + "P";
                    case 18: case 19: case 20:
                        return (d / 1e18).ToString() + "E";
                    case 21: case 22: case 23:
                        return (d / 1e21).ToString() + "Z";
                    default:
                        return (d / 1e24).ToString() + "Y";
                }
            }
            else if (Math.Abs(d) > 0)
            {
                switch ((int)Math.Floor(exponent))
                {
                    case -1: case -2: case -3:
                        return (d * 1e3).ToString() + "m";
                    case -4: case -5: case -6:
                        return (d * 1e6).ToString() + "μ";
                    case -7: case -8: case -9:
                        return (d * 1e9).ToString() + "n";
                    case -10: case -11: case -12:
                        return (d * 1e12).ToString() + "p";
                    case -13: case -14: case -15:
                        return (d * 1e15).ToString() + "f";
                    case -16: case -17: case -18:
                        return (d * 1e18).ToString() + "a";
                    case -19: case -20: case -21:
                        return (d * 1e21).ToString() + "z";
                    default:
                        return (d * 1e24).ToString() + "y";
                }
            }
            else
            {
                return "0";
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All of my string delete's with regex use gsub, is there a shorter way?
Is there any way in Delphi 5 to convert a string to a TDateTime
Is there any efficient way to convert an NSDate to RFC 2822 Date format
Is there any way to make TypeDescriptor.GetConverter.ConvertFromString convert to DateTime using a custom format
Is there a way to use ArrayList() method to add strings to an array
Is there a way to use PowerShell to view the contents of the GAC?
Is there a way to use the CompiledQuery.Compile method to compile the Expression associated
Is there any way to use server controls in ASP.NET MVC? Specifically I need
Is there a way to use ASP.NET in browsers that javascript is not enabled?
Is there any way to use ActiveRecord calculations while also acquiring relevant field names?

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.