Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualChad Smith

Posted 14 March 2013 - 03:26 PM

Thanks.  As soon as I posted this I remembered the C++11 functions so I went to the documentation to see about what it would return if the conversion wasn't possible.  I would more than likely use the C++11 in a true project, though I am writing some helper functions to just help me with some university projects.  The submission system compiler doesn't support a lot of C++11 right now it seems.  I will more than likely just throw an exception if the conversion could not be preformed.

 

Thanks SiCrane on the suggestion for checking if the rest of the string is a valid number also.  I actually did write a helper function already that loops through every character of the string to see if it is a valid char for a number (0-9, negative sign, or a decimal).  Also, just for learning and getting better: is their a better way to do it?  It would just seem on computers these days since a numerical string more than likely wouldn't be very long that it wouldn't take long to just loop through every character and checking each character while they are still valid numerical characters.


#1Chad Smith

Posted 14 March 2013 - 03:18 PM

Thanks.  As soon as I posted this I remembered the C++11 functions so I went to the documentation to see about what it would return if the conversion wasn't possible.  I would more than likely use the C++11 in a true project, though I am writing some helper functions to just help me with some university projects.  The submission system compiler doesn't support a lot of C++11 right now it seems.  I will more than likely just throw an exception if the conversion could not be preformed.

 

Thanks SiCrane on the suggestion for checking if the rest of the string is a valid number also.  I actually did write a helper function already that loops through every character of the string to see if it is a valid char for a number (0-9 or a decimal).  Also, just for learning and getting better: is their a better way to do it?  It would just seem on computers these days since a numerical string more than likely wouldn't be very long that it wouldn't take long to just loop through every character and checking each character while they are still valid numerical characters.


PARTNERS