Thread: I don't really understand the conversion specifier e and g

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    7

    I don't really understand the conversion specifier e and g

    I don't really understand the meaning of the code below

    printf("%12.5e\n", 30.253);
    printf("%-6.2g", .0000009979);

    their are printed out as:

    3.02530e+001
    1e-006

    Is the number on the right side of the period the reason they both have 2 more 0 after e and the trailing 0 from the first one?

    why can the second one cant be print out as 9.9e-7?

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Read printf format specifiers. It will answer your questions. Additionally, the help file for your compiler will also contain this information.


    EDIT: .....or you could look at all the links posted for you on your first thread which answered this question already.
    Last edited by AndrewHunter; 08-10-2011 at 09:03 PM.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    7
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conversion Specifier
    By Nextstopearth in forum C Programming
    Replies: 4
    Last Post: 09-12-2008, 08:31 PM
  2. Format Specifier
    By babu in forum C Programming
    Replies: 2
    Last Post: 06-27-2007, 11:17 PM
  3. Conversion specifier
    By babu in forum C Programming
    Replies: 1
    Last Post: 06-25-2007, 12:09 AM
  4. format specifier
    By s_siouris in forum C Programming
    Replies: 5
    Last Post: 05-13-2006, 05:22 AM
  5. what does the conversion specifier "%*" mean?
    By winbill in forum C Programming
    Replies: 2
    Last Post: 10-14-2001, 02:10 AM