converting a string to exponential

This is a discussion on converting a string to exponential within the C Programming forums, part of the General Programming Boards category; How do you convert a string: "2.416919E-02" "-6.735472E-03" "-3.313178E-04" To exponential numbers? I've tried atof(stringName) and it gives me some ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    4

    converting a string to exponential

    How do you convert a string:
    "2.416919E-02"
    "-6.735472E-03"
    "-3.313178E-04"

    To exponential numbers?

    I've tried atof(stringName) and it gives me some really messed up numbers, and I'm at a loss as to what to do to get the conversion to work right.

    Thanks in advance for the assist,
    Addison

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    4
    nevermind found a way by using


    printf("word = %s, currentForce = %e", word, currentForce);


    Thanks anyways for looking.
    Addison

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    4

    whops

    sscanf(word,"%lf",&currentForce);

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Wow, your first three posts all together in one thread

    There's some number reading help here if you're interested. Also, check out strtod().
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 05:30 PM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 07:02 AM
  3. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 10:11 AM
  4. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21