Thread: Formating Scientific Notation Output

  1. #1
    Registered User
    Join Date
    Dec 2005

    Formating Scientific Notation Output

    Is there a way to format a double in a specific scientific notation form

    double d=123456789;

    printf(buf, "%+10.9E", d)

    results in +1.23456789+08E

    How could I get a result to be

    +0.123456789+09E (zero based)





    Thanks for any help!!!
    Is this done any easier in C++?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    I don't know if something like this would be of any help:
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    You could probably cook something up with sprintf() and some string manipulation to reposition the decimal point and reformat the exponent.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2d game
    By JordanCason in forum Game Programming
    Replies: 5
    Last Post: 12-08-2007, 10:08 PM
  2. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 06:02 PM
  3. Control different DA output value!
    By Hunterhunter in forum A Brief History of
    Replies: 1
    Last Post: 03-13-2003, 12:11 PM
  4. Formatting Scientific Notation output
    By mashley in forum C Programming
    Replies: 5
    Last Post: 02-10-2003, 12:30 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM