Esempio n. 1
0
DataBits MtBBUserData::getA1DataBitsHigh(void){ 

    if (base10(bbb.a1databitshigh, 2) == 0)
        return db8;
    else
        return db7;
}
Esempio n. 2
0
std::string BigInteger::encodeDecimal(unsigned char* buffer, unsigned long bufferLength)
{
	int indiceDeSeguridad = 2048; // Para no entrar en un bucle infonito.
	BigInteger hexserial(bufferLength);
	memcpy(hexserial.m_buffer, buffer,bufferLength);
	
	BigInteger base10(1);

	base10[0] = 0x0A;

	BigInteger cero(1);
	cero[0] = 0;

	char b[100];
	std::string decimalStr = "";

	while((!(hexserial == cero))&&(indiceDeSeguridad--))
	{
		long resto = hexserial % base10;
		hexserial = hexserial / base10;
		ltoa(resto,b,10);
		decimalStr = std::string(b) + decimalStr;
	}


	return decimalStr;
}
Esempio n. 3
0
DataBits MtBBUserData::getA1DataBitsLow(void) { 

    if (base10(bbb.a1databitslow, 2) == 0)
        return db8;
    else
        return db7;
}
Esempio n. 4
0
BitRate MtBBUserData::getA1BaudHigh(void){

    switch (base10(bbb.a1baudhigh, 2)) {
    case 0x01:
        return br2400;
    case 0x02:
        return br4800;
    case 0x03:
        return br9600;
    case 0x04:
        return br19200;
    case 0x05:
        return br38400;
    case 0x06:
        return br57600;
    case 0x07:
        return br115200;
    default:
        return brdefault;
    }
}
int main(int argc, char *argv[])
{
	if(argc!=4){
		printf("Wrong number of arguments\n");
		return 0;
	}
	char *s;
	int q,base1,base2;
	
	
	base1 = atoi(argv[1]);
	base2 = atoi(argv[2]);
	s = argv[3];	
		
	char temp;
	if (checkbase(s,base1))
	{
		q=base10(s,base1);
		ConvertToBase(q,base2);
	}
	else
	printf("Output: 0\n");	
	return 0;
}
Esempio n. 6
0
static ssize_t
numFromStr(const char *src, size_t *len, void **dst, int tp, bool external)
{
	const char *p = src;
	size_t sz = ATOMsize(tp);
#ifdef HAVE_HGE
	hge base = 0;
#else
	lng base = 0;
#endif
	int sign = 1;

	/* a valid number has the following syntax:
	 * [-+]?[0-9]+([eE][0-9]+)?(LL)? -- PCRE syntax, or in other words
	 * optional sign, one or more digits, optional exponent, optional LL
	 * the exponent has the following syntax:
	 * lower or upper case letter E, one or more digits
	 * embedded spaces are not allowed
	 * the optional LL at the end are only allowed for lng and hge
	 * values */
	atommem(sz);

	if (GDK_STRNIL(src)) {
		memcpy(*dst, ATOMnilptr(tp), sz);
		return 1;
	}

	while (GDKisspace(*p))
		p++;
	if (!num10(*p)) {
		switch (*p) {
		case 'n':
			if (external) {
				memcpy(*dst, ATOMnilptr(tp), sz);
				if (p[1] == 'i' && p[2] == 'l') {
					p += 3;
					return (ssize_t) (p - src);
				}
			}
			GDKerror("not a number");
			goto bailout;
		case '-':
			sign = -1;
			p++;
			break;
		case '+':
			p++;
			break;
		}
		if (!num10(*p)) {
			GDKerror("not a number");
			goto bailout;
		}
	}
	do {
		int dig = base10(*p);
		if (base > maxdiv[1].maxval ||
		    (base == maxdiv[1].maxval && dig > maxmod10)) {
			/* overflow */
			goto overflow;
		}
		base = 10 * base + dig;
		p++;
	} while (num10(*p));
	if ((*p == 'e' || *p == 'E') && num10(p[1])) {
		p++;
		if (base == 0) {
			/* if base is 0, any exponent will do, the
			 * result is still 0 */
			while (num10(*p))
				p++;
		} else {
			int exp = 0;
			do {
				/* this calculation cannot overflow */
				exp = exp * 10 + base10(*p);
				if (exp >= (int) (sizeof(maxdiv) / sizeof(maxdiv[0]))) {
					/* overflow */
					goto overflow;
				}
				p++;
			} while (num10(*p));
			if (base > maxdiv[exp].maxval) {
				/* overflow */
				goto overflow;
			}
			base *= maxdiv[exp].scale;
		}
	}
	base *= sign;
	switch (sz) {
	case 1: {
		bte **dstbte = (bte **) dst;
		if (base < GDK_bte_min || base > GDK_bte_max) {
			goto overflow;
		}
		**dstbte = (bte) base;
		break;
	}
	case 2: {
		sht **dstsht = (sht **) dst;
		if (base < GDK_sht_min || base > GDK_sht_max) {
			goto overflow;
		}
		**dstsht = (sht) base;
		break;
	}
	case 4: {
		int **dstint = (int **) dst;
		if (base < GDK_int_min || base > GDK_int_max) {
			goto overflow;
		}
		**dstint = (int) base;
		break;
	}
	case 8: {
		lng **dstlng = (lng **) dst;
#ifdef HAVE_HGE
		if (base < GDK_lng_min || base > GDK_lng_max) {
			goto overflow;
		}
#endif
		**dstlng = (lng) base;
		if (p[0] == 'L' && p[1] == 'L')
			p += 2;
		break;
	}
#ifdef HAVE_HGE
	case 16: {
		hge **dsthge = (hge **) dst;
		**dsthge = (hge) base;
		if (p[0] == 'L' && p[1] == 'L')
			p += 2;
		break;
	}
#endif
	}
	while (GDKisspace(*p))
		p++;
	return (ssize_t) (p - src);

  overflow:
	while (num10(*p))
		p++;
	GDKerror("overflow: \"%.*s\" does not fit in %s\n",
		 (int) (p - src), src, ATOMname(tp));
  bailout:
	memcpy(*dst, ATOMnilptr(tp), sz);
	return -1;
}
Esempio n. 7
0
Parity MtBBUserData::getA1ParityHigh(void){ return (Parity)base10(bbb.a1parityhigh, 2); }
Esempio n. 8
0
Parity MtBBUserData::getA1ParityLow(void){ return (Parity)base10(bbb.a1paritylow, 2); }
Esempio n. 9
0
LANSensitivity MtBBUserData::getSensitivityHigh(void){ return (LANSensitivity)base10(bbb.lansensitivityhigh, 2); }
Esempio n. 10
0
int MtBBUserData::getLanTimeout(void) { return base10(bbb.lantimeout, 2); }
Esempio n. 11
0
LANSensitivity MtBBUserData::getSensitivityLow(void){ return (LANSensitivity)base10(bbb.lansensitivitylow, 2); }
Esempio n. 12
0
LANBitRate MtBBUserData::getLanBaudHigh(void) { return (LANBitRate)base10(bbb.lanbaudhigh, 2); }
Esempio n. 13
0
LANBitRate MtBBUserData::getLanBaudLow(void) { return (LANBitRate)base10(bbb.lanbaudlow, 2); }
Esempio n. 14
0
int MtBBUserData::getBlocksLength(void) { return base10(syb.userbbln, 2); }                
Esempio n. 15
0
int MtBBUserData::getHeadClock(void) { return base10(syb.ck, 2); }