示例#1
0
static double str2float( const char* str, char** endptr )
{
	double sign = is_sign(*str) && *str++ == '-' ? -1 : 1;
	double result = 0;
	
	while( is_dec(*str) )
		result = (result * 10) + (*str++ - '0');
		
	if( *str == '.' )
	{
		++str;
		double fraction = 1;
		while( is_dec(*str) )
			fraction *= 0.1, result += (*str++ - '0') * fraction;
	}
	
	if( *str == 'e' || *str == 'E' )
	{
		++str;
		double base = is_sign(*str) && *str++ == '-' ? 0.1 : 10;
		int exponent = 0;
		while( is_dec(*str) )
			exponent = (exponent * 10) + (*str++ - '0');
		double power = 1;
		for( ; exponent; exponent >>= 1, base *= base )
			if( exponent & 1 )
				power *= base;
				
		result *= power;
	}
char *
sial_getbtypename(int typattr)
{
    int i;
    char *name=sial_alloc(200);

    name[0]='\0';
    for(i=0; i<sizeof(blut)/sizeof(blut[0]); i++) {

        /* skip sign attr. if defaults */
        if(is_sign(blut[i].btype)) {

            if(!(typattr & B_USPEC)) continue;
            if(typattr & B_INT) {
                if(blut[i].btype==B_SIGNED) continue;
            } else if(typattr & B_CHAR) {
                if(blut[i].btype == defbsign) continue;
            } else if(blut[i].btype==B_UNSIGNED) continue;
        }

        if(typattr & blut[i].btype) {

            strcat(name, blut[i].name);
            if(i<(sizeof(blut)/sizeof(blut[0]))-1) {

                strcat(name, " ");
            }
        }
    }
    return name;
}
示例#3
0
/* Compares if the strins match except for a sign at the end
 * of (only) one of the two.
 */
static int neq_str_sign(const char *a1, const char *a2)
{
    int l1, l2, lm;

    l1 = (int)strlen(a1);
    l2 = (int)strlen(a2);
    lm = std::min(l1, l2);

    if (lm >= 1 &&
        ((l1 == l2+1 && is_sign(a1[l1-1])) ||
         (l2 == l1+1 && is_sign(a2[l2-1]))) &&
        gmx_strncasecmp(a1, a2, lm) == 0)
    {
        return lm;
    }
    else
    {
        return 0;
    }
}
示例#4
0
文件: 7a.c 项目: 7shi/Betelgeuse
void parse_fp(enum Op op)
{
    enum Regs fa, fb, fc;
    enum Token token;
    if (!read_reg(&fa, 0)) return;
    token = read_token();
    if ((token == EndL || token == EndF) && (op == Mf_fpcr || op == Mt_fpcr))
        assemble_fp(op, fa, fa, fa);
    else if (is_sign(token, ",") && read_reg(&fb, 0) && read_sign(",") && read_reg(&fc, 0))
        assemble_fp(op, fa, fb, fc);
}
示例#5
0
float strtofloat(char *str)
{
	char sign='+' ;float value; 		//assuming no sign as positive
	if(is_sign(*str)){
		sign=*str;
		str++;
	}
	char integ[MAXSTR],deci[MAXSTR];
	filter(str,integ,deci);
	value = process_integral(integ)+process_decimal(deci);
	if(sign=='+') return value;
	return -value;
}
示例#6
0
文件: clj.c 项目: wildthink/planck
static int at_number(clj_Reader *r, wint_t c) {
  return iswdigit(c) || (is_sign(c) && iswdigit(peek_char(r)));
}
示例#7
0
文件: 7a.c 项目: 7shi/Betelgeuse
int read_sign(const char *sign)
{
    return is_sign(read_token(), sign);
}