void right_output() //该函数将最终运算结果(十进制浮点数)转换成想要进制对应的字符串,显示到文本框中 { char num[50]; gcvt(a,50,num); //该库函数将十进制浮点数转换成十进制的字符串 if(principle==16) { conversion(num,10,16); gtk_entry_set_text(GTK_ENTRY(entry),out); } if(principle==10) { gtk_entry_set_text(GTK_ENTRY(entry),num); } if(principle==8) { conversion(num,10,8); gtk_entry_set_text(GTK_ENTRY(entry),out); } if(principle==2) { conversion(num,10,2); gtk_entry_set_text(GTK_ENTRY(entry),out); } a=0; b=0; method=0; }
void rgb_hexi(){ int r, g, b; scanf("%d,%d,%d", &r, &g, &b); printf("#"); conversion(r); conversion(g); conversion(b); }
int main() { double z, zn = 0, t, M_1, M_2, L_1, L_2, h, s, DeltaM, ratio_M, ratio_L; int i, n = 1000, graph_type; //set up multiple file output char buf[0x100]; snprintf(buf, sizeof(buf), "/Users/cosimacalder/documents/J/J_PROJECT/work/work/DeltaM.txt"); //sets variable name of outputted data file FILE *file = fopen(buf, "w"); //writes to file if (file != NULL) //checks file exists { for (M_1 = 1e-5; M_1 < 1e5; M_1 = M_1 * 1.1) { for (z = 0.01 ; z <= 15; z = z * 1.1) { h = (zn - z) / n; s = y(z) + y(zn); for (i = 1; i < n; i++) { s += 2 * y(z + i * h); } t = 1 / (3 * H_0 * OMEGA_0 * pow((1 + z), (3 / 2))); DeltaM = (h / 2) * s * pow(M_1 , 1.1); M_2 = M_1 + DeltaM; ratio_M = M_1 / M_2; L_1 = conversion(z, M_1); L_2 = conversion(z, M_2); ratio_L = L_1/ L_2; fprintf(file, "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", z, t, L_1, L_2, ratio_L, M_1, M_2, ratio_M); //printf("%lf\t%lf\t%lf\t%lf\t\n", DeltaM); } fprintf(file, "\n"); } } fclose(file); //closes the file for (graph_type = 1 ; graph_type <= 2; graph_type ++) { plot_results(graph_type); } return 0; }
void ft_sendtoprintn(ULLI n, t_pf *pf) { if (n == (ULLI)0) pf->zero = 1; if (pf->type == 'x') ft_print_n(conversion(n, 16, B16MIN), pf); else if (pf->type == 'X') ft_print_n(conversion(n, 16, B16MAJ), pf); else if (pf->type == 'o' || pf->type == 'O') ft_print_n(conversion(n, 8, B8), pf); else if (pf->type == 'b' || pf->type == 'B') ft_print_n(conversion(n, 2, B2), pf); else ft_print_n(conversion(n, 10, B10), pf); }
float lm335::readlm335() { int degC = 0; int degC1 = 0; int degC2 = 0; int degC3 = 0; float dataReaded = 0; degC = analogRead(_pin); degC1 = analogRead(_pin); degC2 = analogRead(_pin); degC3 = analogRead(_pin); degC=(degC1+degC2+degC3)/3; dataReaded = (degC*5 / 1024.0 *1000/10)-273.15; if (_unit==C){ } else { dataReaded=conversion(dataReaded, _unit); } return dataReaded; }
ConversionPtr ParseConversion(const JSONValue& doc) { // Required: dict DictPtr dict = ParseDict(GetObjectProperty(doc, "dict")); ConversionPtr conversion(new Conversion(dict)); return conversion; }
int main (void) { FILE *fin, *fout; int n, s, i, j, count; char t[MAXCHAR]; fin = fopen("dualpal.in", "r"); fout = fopen("dualpal.out", "w"); fscanf(fin, "%d %d", &n, &s); for (i = s + 1; n; i++) for (count = 0, j = 2; j < 11; j++) { conversion(j, i, t); if (pal(t)) count++; if (count > 1) { fprintf(fout, "%d\n", i); n--; break; } } return 0; }
// Reecriture de fprintf present dans la libc. int fecriref(FICHIER* f, char* format, ...) { va_list ap; //structure interne au compilateur pour savoir ou il en est. va_start(ap, format); //Il faut lui donner le dernier parametre connu avant les "..." a savoir format. int i = 0; while(*(format+i) != '\0') { if (*(format+i) == '%') { i++; switch(*(format+i)) { case 'c' : { int c = va_arg(ap, int); ecrire(&c, sizeof(char), 1, f); break; } case 'd' : { int d = va_arg(ap, int); char* chaine = conversion(d); ecrire(chaine, strlen(chaine), 1, f); break; } case 's' : { char* s = va_arg(ap, char*); ecrire(s, strlen(s), 1, f); break; } } } else {
void main() { int hex; int value; int select = 1; while(select) { printf("*******************************************\n"); printf("* [1] 输入转换进制和需要被转换的十进制数 *\n"); printf("* [0] 退出 *\n"); printf("*******************************************\n"); printf("请输入操作选项:"); scanf("%d", &select); if(select == 0) break; else if(select == 1) { printf("请输入转换进制:"); scanf("%d", &hex); printf("请输入要转换的十进制数(-1结束):"); while(scanf("%d", &value), value != -1) { conversion(hex, value); } } else printf("输入有误,请重新输入.\n"); } }
//You give it a vallut and the specific timer you want to star. // YOu have four timers just start with timer zero // The speed of counter or number ticks depends on qemu hertz speed // we don't know he start of it but it should be around 10 milliseconds // per proccess. // ex: start_timer_interrupts(0,10) which means start timer(0) // and interrupt every 10 clicks. int start_timer_interrupts(int timer_index,int milliseconds){ // conversion(timer_index, milliseconds); if(timer_index < 4 && timer_index >= 0){ int clicks=conversion(timer_index, milliseconds); set_background_load_value(timer_index, clicks); set_periodic_mode(timer_index); enable_timer_interrupt(timer_index); timer_start(timer_index); // return 0; } // return -1; //just testing code //int count=0; /*while(1){ os_printf("\n%d",get_current_timer_value(timer_index)); if(get_current_timer_value(timer_index)==0){ os_printf("\nInterrupt Control Val:%X \t Process Val:%X\t VIC Val:%X\t",get_timer_control_value(timer_index),get_proc_status(),mmio_read(VIC_INT_ENABLE)); // count++; } // if(get_current_timer_value(timer_index)==0){ // hw_interrupt_enable(4); /// } // if(get_current_timer_value(timer_index==9&count>0)) // hw_interrupt_enable(4); } */ return 0; }
void testStack() { int choice = 1; while (choice) { printf("please input your choice:\n"); printf("0 exit\n"); printf("1 test basic stack\n"); printf("2 test number system conversion\n"); printf("3 test parenthesis matching\n"); printf("4 test line edit\n"); scanf_s("%d", &choice); switch (choice) { case 0: return; case 1: testBasicStack(); break; case 2: conversion(); break; case 3: parenthesisMatch(); break; case 4: lineEdit(); break; default: break; } } }
void ConversionParser::get_conversions( UTFCaseChanger *chng ) { changer = chng; try { // for error handling { // ( ... )* for (;;) { if ((LA(1) == NUMBER)) { conversion(); } else { goto _loop3; } } _loop3:; } // ( ... )* } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { reportError(ex); recover(ex,_tokenSet_0); } }
double QsfpModule::getQsfpSensor(SffField field, double (*conversion)(uint16_t value)) { auto info = SffFieldInfo::getSffFieldAddress(qsfpFields, field); const uint8_t *data = getQsfpValuePtr(info.dataAddress, info.offset, info.length); return conversion(data[0] << 8 | data[1]); }
inline wstring utf8ToWide( const string& in ) throw() { int length = MultiByteToWideChar( CP_UTF8, 0, in.c_str(), -1, nullptr, 0 ); if ( length == 0 ) return wstring(); vector<wchar_t> conversion( length ); MultiByteToWideChar( CP_UTF8, 0, in.c_str(), -1, &conversion[0], length ); return wstring( &conversion[0] ); }
inline string wideToUtf8( const wstring& in ) throw() { int length = WideCharToMultiByte( CP_UTF8, 0, in.c_str(), -1, nullptr, 0, 0, FALSE ); if ( length == 0 ) return string(); vector<char> conversion( length ); WideCharToMultiByte( CP_UTF8, 0, in.c_str(), -1, &conversion[0], length, 0, FALSE ); return string( &conversion[0] ); }
int main(){ maxlen(); //sets maxlen to 3 straight(); mixed(); straightRev(); singlecount(); conversion(); return 0; }
void main() { int n,d; printf ("Input the integer you want to transform:\n"); scanf("%d",&n); printf ("Input the integer of the system:\n"); scanf("%d",&d); printf ("result:\n"); conversion(n,d); }
void main() { clrscr(); int a,b,c,d,A,B,C,i,cont; float q,r,s,m,h,o; float fx[n],fy[n],x[n],ea[n],er[n],X; gotoxy(25,1);cout<<"axü-bxý+cx-d"; gotoxy(25,2);cout<<"_xü-__xý+_x-_"; gotoxy(55,1);cout<<"Xo = "; gotoxy(55,2);cout<<"X = "; gotoxy(25,2);cin>>a; gotoxy(29,2);cin>>b; gotoxy(34,2);cin>>c; gotoxy(37,2);cin>>d; gotoxy(60,1);cin>>x[0]; gotoxy(60,2);cin>>X; fx[0]=(a*(pow (x[0],3)))-(b*(pow (x[0],2)))+(c* x[0])-d; fx[0]=conversion(fx[0]); fy[0]=((a*3)*(pow (x[0],2)))-((b*2)*x[0])+c; fy[0]=conversion(fy[0]); cont=0; for (i=2; i<=n; i++) { x[i-1] = x[i-2]-(fx[i-2]/fy[i-2]); x[i-1] = conversion(x[i-1]); fx[i-1]=(a*(pow (x[i-1],3)))-(b*(pow (x[i-1],2)))+(c* x[i-1])-d; fx[i-1] = conversion(fx[i-1]); fy[i-1]=((a*3)*(pow (x[i-1],2)))-((b*2)*x[i-1])+c; fy[i-1] = conversion(fy[i-1]); /*x[i]=x[i-1]-(fx[i-1]/fy[i-1]); x[i]=conversion(x[i]);*/ ea[i-1] = X - x[i-1]; ea[i-1] = conversion(ea[i-1]); er[i-1] = (ea[i-1]/X)*100; er[i-1] = conversion(er[i-1]); cont++; if ((ea[i-1]==0) && (er[i-1]==0)) i=n; } for (i=0; i<=cont; i++) { ea[0]=0;er[0]=0; gotoxy(45,5);cout<<"Error Absoluto"; gotoxy(65,5);cout<<"Error Relativo"; gotoxy(10,5);cout<<"fx"; gotoxy(18,5);cout<<"fy'"; gotoxy(30,5);cout<<"x"; gotoxy(2,5);cout<<"Aprox."; gotoxy(2,7+i);cout<< i; gotoxy(8,7+i);cout<< fx[i]; gotoxy(18,7+i);cout<< fy[i]; gotoxy(30,7+i);cout<< x[i]; gotoxy(45,7+i);cout<< ea[i]; gotoxy(65,7+i);cout<< er[i]; } getch(); }
ThresholdLevels QsfpModule::getThresholdValues(SffField field, double (*conversion)(uint16_t value)) { int offset; int length; int dataAddress; ThresholdLevels thresh; CHECK(!flatMem_); getQsfpFieldAddress(field, dataAddress, offset, length); const uint8_t *data = getQsfpValuePtr(dataAddress, offset, length); CHECK_GE(length, 8); thresh.alarm.high = conversion(data[0] << 8 | data[1]); thresh.alarm.low = conversion(data[2] << 8 | data[3]); thresh.warn.high = conversion(data[4] << 8 | data[5]); thresh.warn.low = conversion(data[6] << 8 | data[7]); return thresh; }
int main() { stack s; s.top=-1; int i; char str[SIZE],postfix[SIZE]; printf("\nEnter the string in INFIX form:"); scanf("%s",str); conversion(&s,str,postfix); printf("\nString has been converted to POSTFIX\nPOSTFIX form is:%s",postfix); return 0; }
void number_to_str(float number, char *str, int afterdecimal){ int n, i = 0, index = 0,floatToInt; float afterDecimalPoint; n = (int)number; if (n<0) { n = n*(-1); index++; afterDecimalPoint = (-number) - n; } else afterDecimalPoint = number - n; i = conversion(str, n, index, i); if (afterDecimalPoint<1 && afterdecimal>0) { str[i++] = '.'; for (int k = 0; k < afterdecimal; k++) afterDecimalPoint *= 10; floatToInt = (int)afterDecimalPoint; i=conversion(str, floatToInt, 0, i); } }
int main(int argc, char *argv[]) { int n, d; printf("输入要转换的整数:"); scanf("%d", &n); printf("输入要转换多少进制:"); scanf("%d", &d); printf("转换结果:"); printf("整数%d--->%d进制数\n",n,d); conversion(n, d); putchar(10); return 0; }
int main() { char divisaInicial, divisaFinal; double cantidad, cantidadConvertida; printf("Programa para de conversión de divisas.\n"); entrada(&divisaInicial,&divisaFinal,&cantidad); cantidadConvertida=conversion(divisaInicial,divisaFinal,cantidad); salida(cantidadConvertida); system ("PAUSE"); return 0; }
main() { int lower = 0,upper = 300,step = 20; float fahr, celsius; fahr = lower; printf("FAHRENHEIT-CELSIUS TABLE\n"); while(fahr <= upper) { celsius = conversion(fahr); printf("%3.0f\t%6.1f\n", fahr, celsius); fahr = fahr + step; } }
int main () { int x; double cosseno, valor; printf ("Escolha o valor de x\n"); scanf ("%d", &x ); valor= conversion (x); cosseno = cos2 (valor); printf ("O cosseno de '%d' é: %.10lf\n", x, cosseno); //printf ("%lf\n", cos(valor)); return 0; }
int main(void) { //variable declaration float inch = 0; float centi_converted = 0; //function calls get_inch (&inch); centi_converted = conversion(inch); display (inch, centi_converted); return 0; }
int main(void) { /* comp with 'gcc -lm -o stack' */ Stack *S = (Stack *)malloc(sizeof(Stack)); S->base = NULL; S->top = NULL; S->stacksize = 0; if (!InitStack(S)) exit(ERROR); conversion(S); StackTraverse(S, Visit); putchar('\n'); return 0; }
ReflectedGroupItem::ReflectedGroupItem( const MetaGroupObj * groupObj, ReflectedItem * parent, const std::string & inplacePath ) : ReflectedItem( parent, inplacePath ) , groupObj_( groupObj ) { assert( groupObj_ != nullptr ); std::wstring_convert< Utf16to8Facet > conversion( Utf16to8Facet::create() ); if (groupObj_ == nullptr) { displayName_.clear(); } else { displayName_ = conversion.to_bytes( groupObj_->getGroupName() ); } }
char *pdb_to_molecule(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error) { /* Fix a MySQL end string char issue */ char *inputMol = (char *) malloc(sizeof(char)*(args->lengths[0]+1)); char *outputMol = NULL; const char *inputFormat = "PDB"; const char *outputFormat = MOLECULE_TYPE; if (args->args[0] == NULL) { /* Arguments can not be NULL */ *is_null = 1; *error = 1; free(inputMol); return NULL; } strncpy(inputMol, args->args[0], args->lengths[0]); inputMol[args->lengths[0]] = 0; memset(initid->ptr, 0, sizeof(char)*initid->max_length); *result = 0; *is_null = 0; *error = 0; outputMol = conversion(inputMol, inputFormat, outputFormat); /* Return NULL if the outputMol is empty */ if (outputMol == NULL) { *is_null = 1; *error = 1; free(inputMol); return NULL; } *length = strlen(outputMol); strncat(initid->ptr, outputMol, *length); free(inputMol); free(outputMol); return initid->ptr; }
int main(int argc, char **argv) { tod = argc > 1 ? atoi(argv[1]) : 1; hires = (argc > 2 ? atoi(argv[2]) : 1) * HR_SECOND; normal(); arithmetic(); conversion(); output(); misc(); return 0; }