|
TPCCLIB
|
Decimal point functions. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>#include <ctype.h>#include <unistd.h>#include <math.h>#include "tpcextensions.h"Go to the source code of this file.
Functions | |
| int | strIsValidNumber (const char *s) |
| double | atofVerified (const char *s) |
| int | atofCheck (const char *s, double *v) |
| int | strHaveDecimalComma (const char *s) |
| int | strHaveDecimalSeparator (const char *s) |
| int | atofList (const char *s1, const char *s2, double *x, int maxn) |
Decimal point functions.
Decimal point in data files and user-specified arguments can be either dot (UK/USA) or comma (EU), independent on what is the defined locale on the current platform. Therefore we usually need to try to correctly read decimal numbers whether they are stored in either format, and to convert decimal dots to commas and vice versa. This file contains functions used for that purpose.
Definition in file decpoint.c.
| int atofCheck | ( | const char * | s, |
| double * | v ) |
Verifies that argument string at least seems like a valid number.
Both decimal point and comma are accepted. Optional result double value is set to NaN if string was not valid value.
| s | String which is converted to a double; string must not contain any space characters. |
| v | Pointer to the double float; enter NULL, if not needed. |
Definition at line 94 of file decpoint.c.
Referenced by doubleGetWithUnit(), floatGetWithUnit(), iftGetDoubleValue(), tacReadCarimasTxt(), and tacReadInveonCSV().
| int atofList | ( | const char * | s1, |
| const char * | s2, | ||
| double * | x, | ||
| int | maxn ) |
Read a list of double values from given string with given delimiters.
| s1 | Pointer to string from which double values are read. |
| s2 | String containing character delimiters |
| x | Pointer to a pre-allocated array of doubles. |
| maxn | Size of double list; obligatory. If string contains more values, only maxn values will be read. |
Definition at line 150 of file decpoint.c.
| double atofVerified | ( | const char * | s | ) |
Version of atof() which verifies that argument string at least seems like a valid number.
Both decimal point and comma are accepted. Result value is set to NaN if string was not valid value.
| s | String which is converted to a double; string must not contain any space characters. |
Definition at line 75 of file decpoint.c.
Referenced by atofList(), dcmImgIsotope(), iftGetDoubleWithUnit(), parReadCSV(), parReadFIT(), parReadRES(), tacRead4DM(), tacReadCSV(), tacReadDFT(), tacReadHRPLUSHC(), tacReadHRRTHC(), tacReadMat(), tacReadPMOD(), tacReadQView(), tacReadSIF(), and tacReadSimple().
| int strHaveDecimalComma | ( | const char * | s | ) |
Checks whether argument string contains a decimal comma instead of dot.
| s | Pointer to string. |
Definition at line 115 of file decpoint.c.
Referenced by tacReadCSV().
| int strHaveDecimalSeparator | ( | const char * | s | ) |
Checks whether argument string contains a decimal comma or dot, or neither.
| s | Pointer to string. |
Definition at line 132 of file decpoint.c.
| int strIsValidNumber | ( | const char * | s | ) |
Verifies that given string seems like a valid representation of integer or floating point number in decimal or exponential format.
| s | Pointer to the string to be verified; it must not contain any leading or trailing space characters etc, or it will never verify. |
Definition at line 33 of file decpoint.c.
Referenced by atofCheck(), and atofVerified().