Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. str to double?

str to double?

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    briefcase
    wrote on last edited by
    #1

    How can i put the contents of a string into a double? 100000000000000000000000000000000 for instance? :) atoi works up to the max value of a int, then it craps out... Thanks

    C S 2 Replies Last reply
    0
    • B briefcase

      How can i put the contents of a string into a double? 100000000000000000000000000000000 for instance? :) atoi works up to the max value of a int, then it craps out... Thanks

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      try atof -c


      Garbage collection, making life better - for weenies!

      Image Processing - make images do the un-natural.

      D 1 Reply Last reply
      0
      • C Chris Losinger

        try atof -c


        Garbage collection, making life better - for weenies!

        Image Processing - make images do the un-natural.

        D Offline
        D Offline
        David Viggiano
        wrote on last edited by
        #3

        If you need some formatting options try sscanf().

        1 Reply Last reply
        0
        • B briefcase

          How can i put the contents of a string into a double? 100000000000000000000000000000000 for instance? :) atoi works up to the max value of a int, then it craps out... Thanks

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          I've always liked strto_x_, as it gives you some idea of whether or not the conversion worked:

          char* mightBeANumber;
          char* pEnd;
          double d = strtod(mightBeANumber, &pEnd);
          if (!*pEnd) {
          // probably worked!
          }

          Just my opinion, anyway. Stuart Dootson 'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups