Thread: Is there an off-the-wall function to translate "5.6e+4" to "56000"?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    Is there an off-the-wall function to translate "5.6e+4" to "56000"?

    Is there an off-the-wall function to translate "5.6e+4" to "56000"?
    Thanks

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    54
    sscanf. Use the %f type specifer. Be sure to look at the example.
    I think you can also do it with a stringstream or something but I'm not sure how.
    Last edited by Doodle77; 03-27-2008 at 08:24 PM.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Code:
    double num = 5.6e+4;
    std::cout << std::fixed << num << std::endl;

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    28
    If thats an output of an equation you have you could also do this. I had the same problem for my program.
    Code:
        cout.setf(ios::fixed);
        cout.setf(ios::showpoint);
        cout.precision(1);
    Change precision accordingly, the 1 would mean like 56000.0, 2 would be 56000.00 etc.

    Hope this helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post your games here...
    By Hammer in forum Game Programming
    Replies: 132
    Last Post: 02-28-2013, 09:29 AM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM