#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
#include <sstream>
#include <o2scl/lib_settings.h>
#include <gsl/gsl_ieee_utils.h>
Go to the source code of this file.
Definition in file string_conv.h.
Functions | |
std::string | ptos (void *p) |
Convert a pointer to a string. | |
std::string | itos (int x) |
Convert an integer to a string. | |
std::string | btos (bool b) |
Convert a boolean value to a string. | |
std::string | dtos (double x, int prec=6, bool auto_prec=false) |
Convert a double to a string. | |
size_t | size_of_exponent (double x) |
Returns the number of characters required to display the exponent of x in scientific mode. | |
std::string | dtos (double x, std::ostream &format) |
Convert a double to a string using a specified format. | |
int | stoi (std::string s) |
Convert a string to an integer. | |
bool | stob (std::string s) |
Convert a string to a boolean value. | |
double | stod (std::string s) |
Convert a string to a double. | |
std::string | double_to_ieee_string (const double *x) |
Convert a double to a string containing IEEE representation. | |
bool | has_minus_sign (double *x) |
Find out if the number pointed to by x has a minus sign. |
std::string btos | ( | bool | b | ) |
This returns "1"
for true and "0"
for false.
std::string double_to_ieee_string | ( | const double * | x | ) |
Modeled after the GSL function gsl_ieee_fprintf_double()
, but converts to a string
instead of a FILE
*.
std::string dtos | ( | double | x, | |
int | prec = 6 , |
|||
bool | auto_prec = false | |||
) |
If auto_prec
is false, then the number is converted to a string in the ios::scientific
mode, otherwise, neither the scientific or fixed mode flags are set and the number is converted to a string in "automatic" mode.
bool has_minus_sign | ( | double * | x | ) |
This function returns true if the number pointed to by x
has a minus sign using the GSL IEEE functions. It is useful, for example, in distinguishing "-0.0" from "+0.0".
std::string ptos | ( | void * | p | ) |
This uses an ostringstream
to convert a pointer to a string and is architecture-dependent.
size_t size_of_exponent | ( | double | x | ) |
This returns 2 or 3, depending on whether or not the absolute magnitude of the exponent is greater than 100. It uses stringstream
to convert the number to a string and counts the number of characters directly.
bool stob | ( | std::string | s | ) |
This returns true only if the string has at least one character and the first non-whitespace character is either t
, T
, or one of the numbers 1 through 9.
This function never fails (it just returns false for an empty string).
double stod | ( | std::string | s | ) |
If this function fails it will call O2SCL_ERR() and return zero.
int stoi | ( | std::string | s | ) |
If this function fails it will call O2SCL_ERR() and return zero.
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page