Beispiel #1
0
string AES::get_est_int_hex (void)
{
  stringstream salida;
  for (unsigned i=0; i<MAX; i++)
  {
    vector<int> v1,v2;
    for (int j=(BITS-1); j>3; j--)
      v1.push_back(est_int[i][j]);
    salida<<hex<<to_decimal(v1);

    for (int j=3; j>-1; j--)
      v2.push_back(est_int[i][j]);
    salida<<hex<<to_decimal(v2);
  }
  return salida.str();
}
Beispiel #2
0
decimal Worker::getBoundsHeight()
{
#if USE_CGAL
	CGALPrimitive* pr=dynamic_cast<CGALPrimitive*>(primitive);
	CGAL::Cuboid3 b=pr->getBounds();
	return to_decimal(b.zmax());
#endif
	return 1;
}
void
error_msg(char *msg)
{
	char buf[32];
	print_string(1, msg);
	print_string(1, " ");
	to_decimal(errno, buf);
	print_string(1, buf);
	print_string(1, "\n");
}
Beispiel #4
0
//-----------------------------------------------------------------------------
void *convert(void * mut)
{
    pthread_mutex_t *mutex = (pthread_mutex_t*) mut;

    while(1)
    {
        sem_wait(handlers.sem);
        int time = handlers.shdata->time;
        float latitude = to_decimal(handlers.shdata->latitude);
        float longitude = to_decimal(handlers.shdata->longitude);
        sem_post(handlers.sem);

        pthread_mutex_lock(mutex);
        decimal_coord.time = time;
        decimal_coord.latitude = latitude;
        decimal_coord.longitude = longitude;
        pthread_mutex_unlock(mutex);

        usleep(500000);
    }
}
Beispiel #5
0
int main() {

	int i, length;
	char option, color[13], *temp;
	
	scanf("%c", &option);

	getchar();

	if (option == 'h') {
	    
		fgets(color, 14, stdin);
		length = strlen(color);
		length = color[length - 1] == '\n' ? length - 1 : length;
		to_lower(color, length);
		
		printf("rgb(%d, %d, %d)", to_decimal(color[1], color[2]), to_decimal(color[3], color[4]), to_decimal(color[5], color[6]));
		
	} else if (option == 'd') {
	    
		fgets(color, 14, stdin);
		temp = strtok(color, ", ");
		
		getchar();
		
		printf("#");

		while (temp != NULL) {
			sscanf(temp, "%d", &i);
			print_hex(i);
			temp = strtok(NULL, ", ");
		}
	}
	
	return 0;
}
Beispiel #6
0
void next_commit_id_part1(char* commit_id) {
  /* COMPLETE THE REST */
  // first commit id
  char * d = "000000000000000000000000000000"; //30
  if (strcmp(commit_id, d) == 0) { 
    // to ternary 
    to_61c(commit_id, 1);
  } else {
    // to digit
    to_digit(commit_id);
    // sum as decimal
    int decimal_sum = to_decimal(atoi(commit_id));
    // decimal sum to ternary binary
    to_ternary(decimal_sum + 1, commit_id);
 }
}
Beispiel #7
0
void main()
{
	char s[1000], r[1000];
	int i, j, f, t;
	long n;
	
	//freopen( "a.in", "r", stdin );	
	
	while ( scanf( "%s %d %d", s, &f, &t ) != EOF )
	{
		i = 0;

		while( i < strlen( s ) - 1 && s[i] == '0' )
		{
			++i;
		}

		j = 0;

		while ( i < strlen( s ) )
		{
			r[j++] = s[i++];
		}

		r[j] = 0;

		strcpy( s, r );

		to_decimal( s, f, n );

		to_base_b( n, t, s );

		if ( strlen( s ) > 7 )
		{
			printf( "  ERROR\n" );
		}
		else
		{
			printf( "%7s\n", s );
		}
	}		
}
Beispiel #8
0
void editorShow(unsigned char emode) {
    //char s[3];
    uint8_t show_updown=1;
    uint8_t noexit=0;


    char inp[12];

    switch(emode) {
    case 1:
        editor_baudrate(&BAUDRATE);
        if (editor_changed==1) lcd_clear();
        if (editor_changed==1) fprintf(editor_LCD, "\fBAUDRATE            \n = %ld                 ", BAUDRATE);
        break;
    case 2:
        editor_uint8_turn(&T_INPUT, 0, 2, 1, 1);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fINPUT               \n =                     ");
            if (T_INPUT==0) {
                lcd_pos_string(3,2,"T0");
            } else if (T_INPUT==1) {
                lcd_pos_string(3,2,"T1");
            } else if (T_INPUT==2) {
                lcd_pos_string(3,2,"(T0+T1)/2");
            }
        }

        break;
    case 3:
        editor_int16(&PT100_OFFSET0, -1000, 1000, 1, 10);
        sprintf(inp, "%4d", PT100_OFFSET0);
        to_decimal(inp, 1);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fPT100 OFFSET for T0 \n = %s °C             ", inp);
        }
        sprintf(inp, "%4d", PT1002T(read_adc(1,16), PT100_OFFSET0));
        to_decimal(inp, 1);
        fprintf(editor_LCD, "\vT0=%s°C ", inp);
        break;
    case 4:
        editor_int16(&PT100_OFFSET1, -1000, 1000, 1, 10);
        sprintf(inp, "%4d", PT100_OFFSET1);
        to_decimal(inp, 1);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fPT100 OFFSET for T1 \n = %s °C             ", inp);
        }
        sprintf(inp, "%4d", PT1002T(read_adc(0,16), PT100_OFFSET1));
        to_decimal(inp, 1);
        fprintf(editor_LCD, "\vT1=%s°C ", inp);
        break;
    case 5:
        editor_int16(&PID_P, 0, 1000, 1, 10);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fPID P factor        \n = %d                ", PID_P);
        }
        break;
    case 6:
        editor_int16(&PID_I, 0, 1000, 1, 10);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fPID I factor        \n = %d                ", PID_I);
        }
        break;
    case 7:
        editor_int16(&PID_D, 0, 1000, 1, 10);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fPID D factor        \n = %d                ", PID_D);
        }
        break;
    case 8:
        editor_int32(&PID_IMAX, 0, 1000000, 1, 10);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fPID I_MAX           \n = %ld                ", PID_IMAX);
        }
        break;


    case 9:
        editor_uint16(&FAN_MIN, 0, 100, 1, 2);
        if (editor_changed==1) {
            lcd_clear();
            fprintf(editor_LCD, "\fFAN START TEMP.     \n = %d °C             ", FAN_MIN);
        }
        break;
    case 10:
        editor_int16(&FAN_INCREASE, 0, 100, 1, 2);
        if (editor_changed==1) {
            lcd_clear();
            sprintf(inp, "%4d", FAN_INCREASE);
            to_decimal(inp, 1);
            fprintf(editor_LCD, "\fFAN INCREASE        \n = %s steps/°C             ", inp);
        }
        break;






    case EDITOR_MAXMODE-1:
        editor_restore();
        show_updown=0;
        if (editor_changed==1) lcd_clear();
        if (editor_changed==1) fprintf(editor_LCD, "\frestore defeault    \npress %c             ", EDITOR_ACCEPT_GLYPH);
        noexit=1;
        break;
    case EDITOR_MAXMODE:
        editor_quit();
        show_updown=0;
        if (editor_changed==1) lcd_clear();
        if (editor_changed==1) fprintf(editor_LCD, "\fDONE !!!            \npress %c             ", EDITOR_ACCEPT_GLYPH);
        noexit=1;
        break;
    }

    if (noexit!=1) editor_quit();


    //if (emode<EDITOR_MAXMODE-1) {
        if (show_updown==0) {
            lcd_pos_char(7,4,' ');
            lcd_pos_char(12,4,' ');
        } else {
            lcd_pos_char(7,4,EDITOR_DOWN_GLYPH);
            lcd_pos_char(12,4,EDITOR_UP_GLYPH);
        }

        lcd_pos_char(2,4,EDITOR_ENTER_GLYPH);
        lcd_pos_char(17,4,EDITOR_ACCEPT_GLYPH);
    /*} else {
        lcd_pos_char(10,3,EDITOR_ENTER_GLYPH);
        lcd_pos_char(2,3,EDITOR_ACCEPT_GLYPH);
    }*/
    editor_changed=0;
};
Beispiel #9
0
unsigned int TokenBuilder::buildNumber(QString str)
{
	parserlval.number = new decimal(to_decimal(str));
	return NUMBER;
}