libtpcmisc
 All Data Structures Files Functions Variables Enumerator Defines
Functions
decpoint.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include "include/decpoint.h"
Include dependency graph for decpoint.c:

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)

Function Documentation

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.

Returns:
Returns the double float.
Parameters:
strPointer to string (not modified).

Definition at line 102 of file decpoint.c.

Referenced by atof_with_check().

int atof_with_check ( char *  double_as_string,
double *  result_value 
)

Converts a string to float using strtod(), but if its return value is zero this function checks that argument string actually contains a number.

Returns:
Returns 0 if successful, and 1 in case of an error.
Parameters:
double_as_stringString which is converted to a double; not modified
result_valuePointer to the double float

Definition at line 147 of file decpoint.c.

References atof_dpi().

Here is the call graph for this function:

int dec_comma_is ( char *  str)

Checks whether argument string contains a decimal comma instead of dot.

Returns:
Returns 1 if decimal comma is found and 0 if not found.
Parameters:
strPointer to string (not modified).

Definition at line 57 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 123 of file decpoint.c.

int dec_separator ( char *  str)

Checks whether argument string contains a decimal comma or dot, or neither.

Returns:
Returns 0, if neither is found, 1 if dot, and 2 if comma is found.
Parameters:
strPointer to string (not modified).

Definition at line 71 of file decpoint.c.

void dec_separator_change ( char *  str,
int  decsep 
)

Convert the first decimal separator to comma or dot, as required.

Parameters:
strPointer to string (modified when necessary).
decsepRequested decimal separator: 0=dot, 1=comma.

Definition at line 83 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.

Parameters:
strPointer to string where numerical values are searched; not changed.
nxtpObligatory 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 170 of file decpoint.c.