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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:43:47+00:00 2026-06-04T18:43:47+00:00

How do I display a floating-point number in engineering notation , using C++ Builder

  • 0

How do I display a floating-point number in engineering notation, using C++ Builder String class? (UnicodeString)

Surely there must exist a pre-made function for this? I cannot find one. The only thing I have come across is String::FloatToStrF(), but it doesn’t seem to support engineering notation.

  • 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-06-04T18:43:49+00:00Added an answer on June 4, 2026 at 6:43 pm

    Here is code to print in engineering notation, lifted as-is from this site. I take no credit for any of it.

    #define MICRO "µ"
    
    #define PREFIX_START (-24)
    /* Smallest power of then for which there is a prefix defined.
       If the set of prefixes will be extended, change this constant
       and update the table "prefix". */
    
    #include <stdio.h>
    #include <math.h>
    
    char *eng(double value, int digits, int numeric)
    {
      static char *prefix[] = {
      "y", "z", "a", "f", "p", "n", MICRO, "m", "",
      "k", "M", "G", "T", "P", "E", "Z", "Y"
      }; 
    #define PREFIX_END (PREFIX_START+\
    (int)((sizeof(prefix)/sizeof(char *)-1)*3))
    
          int expof10;
          static unsigned char result[100];
          unsigned char *res = result;
    
          if (value < 0.)
            {
                *res++ = '-';
                value = -value;
            }
          if (value == 0.)
            {
            return "0.0";
            }
    
          expof10 = (int) log10(value);
          if(expof10 > 0)
            expof10 = (expof10/3)*3;
          else
            expof10 = (-expof10+3)/3*(-3); 
    
          value *= pow(10,-expof10);
    
          if (value >= 1000.)
             { value /= 1000.0; expof10 += 3; }
          else if(value >= 100.0)
             digits -= 2;
          else if(value >= 10.0)
             digits -= 1;
    
          if(numeric || (expof10 < PREFIX_START) ||    
                        (expof10 > PREFIX_END))
            sprintf(res, "%.*fe%d", digits-1, value, expof10); 
          else
            sprintf(res, "%.*f %s", digits-1, value, 
              prefix[(expof10-PREFIX_START)/3]);
          return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to represent a floating-point number as a string rounded to some number
I have a floating point number in JavaScript, like 42.563134634634. I want to display
I'd like to display the binary (or hexadecimal) representation of a floating point number.
I recently realized that some countries display floating point numbers with different comma/period notation.
In Java, I can do the following to format a floating point number for
I'd like to display 100 floating cubes using DirectX or OpenGL . I'm looking
I would like R to display floating point numbers only a small amount of
i have floating point variables lmin and lmax. i wish to display only 4
Goal: Display some text with a paired word-for-word translation directly underneath. Text must wrap
I display the contents of a table in the database using a ListBox. Each

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.