ss1d - Scan a double from a string in fixed decimal format


#include "l/l_sys_scan.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

int ss1d
	const char *input_str,
	double *double_ptr


This routine reads a double from a string in fixed decimal format with more sophisticated error reporting that available using scanf. If the contents of "str" is exactly one number which is appropriate for a double, then it sets *double_ptr to that number and returns NO_ERROR. Otherwise and error message is set, and ERROR is returned. The contents of *double_ptr are only changed on success. If str is either "off" or "none", then the special value DBL_NOT_SET is returned. Otherwise, str must contain a single valid number, possibly followed by a "%". If str ends with a "%", then the number is assumed to be a percentage, and the result is divided by 100.0.


If "str" represents a valid double, then NO_ERROR is returned. Otherwise the problem with "str" is reported in the set error message, and ERRROR is returned. The problem with "str" can be printed with kjb_print_error.


For successful return, "str" cannot contain two numbers. For example, it can't be something like "1 2".


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard


ss1ul , ss1l , ss1spl , ss1pl , ss1pl_2 , ss1ui , ss1i , ss1spi , ss1pi , ss1pi_2 , ss1us , ss1s , ss1sps , ss1ps , ss1ps_2 , ss1f , ss1snf , ss1snd