Thread: output is in scientific notation

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    416

    output is in scientific notation

    I have calculation type program that outputs some numbers, but it's always in scientific notation. I would like the number in decimal points only. I have a modeless dialog with an EDITTEXT control that receives the double (output). I'm getting the text from one EDITTEXT (input), converting it to double with strtod(), calculate, then back to string with sprintf(). Is there a way to pass the numbers so they are not in scientific notation when displayed?

    Code:
    GetDlgItemText(hwnd, INPUT, InputText, MAX_PATH);
    rInput = strtod(InputText,NULL);
    
    //.... later in the code
    //the code does some stuff with rInput, and assigns it to Output
    
    sprintf(OutputText,"%e",Output);
    SetDlgItemText(hwnd,OUTPUT,OutputText);

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Use %f instead of %e.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Still does the same thing. If I enter 1, and say the output is 1, it will really output "1.00000e+000", i wouldnt mind if it said 1.0000 but i just dont want the 'e000'

    EDIT: scratch that, i put %f in the wrong sprintf
    Last edited by scwizzo; 09-18-2007 at 10:57 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 03:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM