TPCCLIB
|
Functions for reading real numbers from strings which may contain either decimal dots or commas. More...
#include "libtpcmisc.h"
Go to the source code of this file.
Functions | |
int | dec_comma_is (char *str) |
int | dec_separator (char *str) |
void | dec_separator_change (char *str, int decsep) |
double | atof_dpi (char *str) |
int | dec_nr (char *str) |
int | atof_with_check (char *double_as_string, double *result_value) |
char * | strPtrToNextValue (char *str, char **nxtp) |
int | atoi_with_check (const char *int_as_string, int *result_value) |
Functions for reading real numbers from strings which may contain either decimal dots or commas.
Definition in file decpoint.c.
double atof_dpi | ( | char * | str | ) |
Replacement of atof(), which works whether string contains decimal dots or decimal commas. Possible commas are replaced by dots in the argument string.
str | Pointer to string (not modified). |
Definition at line 59 of file decpoint.c.
Referenced by atof_with_check(), csv2dft_a(), csv2dft_b(), dft_fill_hdr_from_IFT(), dftRead(), fitRead(), and resRead().
int atof_with_check | ( | char * | double_as_string, |
double * | result_value ) |
Converts a string to float using atof(), but if its return value is zero this function checks that argument string actually contains a number. Result value is set to NaN if string was not valid value. Both decimal point and comma are accepted.
double_as_string | String which is converted to a double; not modified |
result_value | Pointer to the double float; enter NULL, if not needed |
Definition at line 107 of file decpoint.c.
Referenced by csv2dft_linkset(), csv2dft_mat(), dftRead(), and readEcat931Calibrationfile().
int atoi_with_check | ( | const char * | int_as_string, |
int * | result_value ) |
Converts a string to integer (int) using atoi, but this function verifies that argument string actually contains an integer number. String must end in NULL character. Exponentials are not accepted. Result value is set to 0 if string was not valid value.
int_as_string | String which is converted to a int; not modified |
result_value | Pointer to the int; enter NULL, if not needed |
Definition at line 238 of file decpoint.c.
Referenced by integerListAddFromString(), and pxlRead().
int dec_comma_is | ( | char * | str | ) |
Checks whether argument string contains a decimal comma instead of dot.
str | Pointer to string (not modified). |
Definition at line 14 of file decpoint.c.
int dec_nr | ( | char * | str | ) |
Returns the number of decimal places in the argument string, representing a floating point value. String can contain either decimal dots or commas.
Definition at line 81 of file decpoint.c.
Referenced by dftRead().
int dec_separator | ( | char * | str | ) |
Checks whether argument string contains a decimal comma or dot, or neither.
str | Pointer to string (not modified). |
Definition at line 28 of file decpoint.c.
void dec_separator_change | ( | char * | str, |
int | decsep ) |
Convert the first decimal separator to comma or dot, as required.
str | Pointer to string (modified when necessary). |
decsep | Requested decimal separator: 0=dot, 1=comma. |
Definition at line 40 of file decpoint.c.
char * strPtrToNextValue | ( | char * | str, |
char ** | nxtp ) |
This function searches the given string for a string representation of numerical value, possibly with decimal and exponent part. Returns also pointer to the string right after where the numerical value ended, and from where the next number can be searched. Return Returns pointer to start of the next string, or NULL if not found.
str | Pointer to string where numerical values are searched; not changed. |
nxtp | Obligatory pointer to string pointer, which will be set to point to the first character after value string, or to NULL if string ends. |
Definition at line 134 of file decpoint.c.