// Common elements
char* to_arc(double bulge, double r, double start_ang, double end_ang, int precision,char* delim, char * units, double scaling, char *out){
	// This is used for arcs, polylines, and lwpolylines
	char temp[50];
	
	// Assume that we are adding to the input and not starting over
	strcat(out," A ");
	// For arcs there is only one radius
	strcat(out,gcvt(scaling*r,precision,temp) );
	strcat(out,",");
	strcat(out,gcvt(scaling*r,precision,temp) );
	
	strcat(out," 0"); // For arc assume no x-axis rotation.  That seems to apply to elipse elements only
	// Determine if it is a large arc
	if ( (end_ang > start_ang) && ( (end_ang - start_ang) > 180) ){
		//strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag
		strcat(out," 1, "); // Large arc flag...Always use a zero sweep flag
	}
	else{
		//strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag
		strcat(out," 0,");
	}
	// This may be easier if I allow r to be plus and minus, but for now this works
	if (bulge > 0){
		strcat(out,"0 ");
	}
	else{
		strcat(out,"1 ");
	}
}
int main()
{
	printf("Task 2! \n");

	float x[N];
	float y;

	generateVector(x);

	// timing
	char buf[50];
	clock_t exec_t1, exec_t2;

	exec_t1 = times(NULL); // get system time before starting the process

	// code START
	y = sumVector (x, N);

	//code END

	exec_t2 = times(NULL); // get system time after finishing the process
	gcvt((exec_t2 - exec_t1), 10, buf);
	// gcvt convert a number to a string with decimal including a point, gcvt(value,number of digits,buffer)
	// buffer 8,9 character longer than number, this is the memory block that stores the number
	alt_putstr("proc time = "); 	alt_putstr(buf);	alt_putstr("ticks\n");
	//printf could be used if memory is enough
	int i;
	for (i=0; i<10; i++)
		y = y/2.0;
	gcvt((int)y, 10, buf);
	alt_putstr("Result (divided by 1014) = "); alt_putstr(buf);
	return 0;
}
// DXF Line -> SVG
char* line2line(line ln, int precision, char * units, double scaling, tables plot_info, char *out){
	// Directly convert DXF to SVG because it works
	char *out_ptr;
	char temp[20];
	entity *ent_ptr = &ln;	
	
	strcpy(out,"<line x1=\"");
	strcat(out,gcvt(ent_ptr->ret_x(),precision,temp) );
	strcat(out,units);
	strcat(out,"\" y1=\"");
	strcat(out,gcvt(-1*ent_ptr->ret_y(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis
	strcat(out,units);
	
	strcat(out,"\" x2=\"");
	strcat(out,gcvt(ln.ret_xf(),precision,temp) );
	strcat(out,units);
	strcat(out,"\" y2=\"");  
	strcat(out,gcvt(-1*ln.ret_yf(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis
	strcat(out,units);
	strcat(out,"\" stroke-width=\"1\" stroke=\"black\" ");
	ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp));
	pattern2dasharray(linfo, precision, scaling, out);  // Add the linetype information
	strcat(out, " />");
		
	out_ptr = out;
	return out_ptr;
}
Example #4
0
int main()
{
  pid_t pid;
  FILE *f;
  char str1[100], str2[100], str3[100];
  if((pid=fork()) == 0)
  {//child
    strcpy (str1,"file_");
    gcvt(getpid(), 12, str3);
    strcat (str1, str3);
    strcat (str1, ".txt");
    f = fopen(str1,"w+");
    fprintf(f, "Parent: %d;\n", getppid());
    fclose(f);
  } 
  else
  {//parent
    strcpy (str2,"file_");
    gcvt(getpid(), 12, str3);
    strcat (str2, str3);
    strcat (str2, ".txt");
    f = fopen(str2, "w+");
    fprintf(f, "I am: %d and my child: %d; \n", getpid(), pid);
    waitpid(pid, NULL, 0);
    fclose(f);
  }
  return 0;
}
Example #5
0
//-------------------------------------------------------------------------------------------
void ShowLambda(void) 
{	char *res;
	long ver = 0;
	res = (char *)malloc(20);

	// calculate display precision
	if ( dblLambda >= 1000.0 ) ver = 2; else ver = 1;
	if ( iVersion >= 4 ) 
		ver += iVersion;

	if ( dblLambda < 1.0 ) 
	{
		gcvt(dblLambda, 2, res);
		// < 1 is errorvalue, so write w/o "nm"
		SetDlgItemText(hwDlg, IDC_LAMBDA, res);
	}
	else
	{
		gcvt(dblLambda, ver, res);
		wsprintf(cBuffer, lpszLambdaTemplate, res);
		// finally here write the calculated wavelength
		SetDlgItemText(hwDlg, IDC_LAMBDA, cBuffer);
	}

	free(res);
}
Example #6
0
void main()
  {
    char buffer[80];

    printf( "%s\n", gcvt( -123.456789, 5, buffer ) );
    printf( "%s\n", gcvt( 123.456789E+12, 5, buffer ) );
  }
// DXF Insert -> SVG
char* insert2group(insert in, int precision, char * units, double scaling, tables plot_info, blocks blks, char *out){
	char *out_ptr;
	char tmp_char[100000];
	
	//  get the block using the name from the insert information
	block blk = blks.ret_block(in.name(tmp_char));
	
	entity *ent_ptr = &in;
	entities *ents_ptr = &blk;
	// For now just translations  MBS 22 Aug 05
	strcpy(out, "<g transform=\"matrix(1,0,0,1,");
	strcat(out,gcvt(scaling*ent_ptr->ret_x(),precision,tmp_char) );
	strcat(out,",");
	strcat(out,gcvt(-scaling*ent_ptr->ret_y(),precision,tmp_char) );
	strcat(out,")\" >\n");
	
	
	// Now convert the entities in the block
	std::vector< polyline > plines = ents_ptr->ret_plines();
	std::vector< lwpolyline > lwplines = ents_ptr->ret_lwplines();
	std::vector< arc > arcs = ents_ptr->ret_arcs();
	std::vector< circle > circs = ents_ptr->ret_circles();
	std::vector< line > lns = ents_ptr->ret_lines();
	std::vector< text > txts = ents_ptr->ret_texts();
	
		
	
	for(int i = 0; i < plines.size();i++){
		strcat( out,pline2pline(plines[i], units, scaling, plot_info ) );
		strcat( out, "\n" );
	}
	for(int i = 0; i < lwplines.size();i++){
		strcat( out,lwpline2path(lwplines[i], units, scaling, plot_info ) );
		strcat( out, "\n" );
	}
	for(int i = 0; i < arcs.size();i++){
		strcat( out, arc2path(arcs[i], 6,units, scaling, plot_info, tmp_char ) );
		strcat( out, "\n" );
	}
	for(int i = 0; i < circs.size();i++){
		strcat( out, circle2circle(circs[i], 6, units, scaling, plot_info, tmp_char) );
		strcat( out, "\n" );
	}
	for(int i = 0; i < lns.size();i++){
		strcat( out, line2line(lns[i], 6, units, scaling, plot_info, tmp_char) );
		strcat( out, "\n" );
	}
	for(int i = 0; i < txts.size();i++){
		strcat( out, text2text(txts[i], 6, units, scaling, plot_info, tmp_char) );
		strcat( out, "\n" );
	}
	// End the group
	strcat(out,"</g>");
	
	out_ptr = out;
	return out_ptr;	
}
Example #8
0
void QRap::GetLink(double lat, double lon)
{
	cout << "mMouseType = CLEAN in QRap::GetLink(double lat, double lon)" << endl;
	mMouseType = CLEAN;
	char Lat[33];
	char Lon[33];
	gcvt(lat,8,Lat);
	gcvt(lon,8,Lon);
	string query = "SELECT id, txinst,rxinst, linkname, frequency, kfactor ";
	query += "FROM links WHERE line && ST_GeomFromText('POINT(";
	query +=  Lon;
	query += " ";
	query += Lat;
	query += ")',4326)";
	if (!gDb.PerformRawSql(query))
	{
		cout << "In QRap::GetLink(...)  Database link select failed"<< endl;
	}
	else
	{
		pqxx::result Li;
		gDb.GetLastResult(Li);
		if (Li.size()>0)
		{
			cout << "In QRap::GetLink(...) Database link select suceeded" << endl;
			int ID =(int)atof(Li[0]["id"].c_str()) ;
			int TxID =(int)atof(Li[0]["txinst"].c_str()) ;
			int RxID = (int)atof(Li[0]["rxinst"].c_str());
			double frequency = (double)atof(Li[0]["frequency"].c_str());
			double kfactor = (double)atof(Li[0]["kfactor"].c_str());
			string name = Li[0]["linkname"].c_str();
			cout << name << endl;
			cConfirmLink *ConfirmLink = new cConfirmLink(mQGisIface->mainWindow(), QgisGui::ModalDialogFlags);
			cout << "In QRap::GetLink(...) After constructor " << endl;
			if (ConfirmLink->SetOldLink(ID,TxID,RxID,name,frequency, kfactor))
			{
				cout << "In QRap::GetLink(...) SetOldLink success " << endl;
				if (ConfirmLink->exec()==1)
				{
					cLinkAnalysis *Plot = new cLinkAnalysis(mQGisIface->mainWindow(), QgisGui::ModalDialogFlags);
					Plot->DoAndSetUpDisplay(ConfirmLink->Units, ConfirmLink->Downlink, ConfirmLink->Frequency,
							ConfirmLink->kFactor, ConfirmLink->PlotResolution,
							ConfirmLink->DEMsource,	ConfirmLink->ClutterSource, ConfirmLink->UseClutter,
							ConfirmLink->TxID, ConfirmLink->RxID, ConfirmLink->mLinkName,
							ConfirmLink->TxName, ConfirmLink->RxName, ID);
					if (Plot->exec())
					{
						mQGisIface->mapCanvas()->refresh();
					}
				}
			}
		}	
	}
}
Example #9
0
void SerialCom::comCallBack(const dlut_move_base::Velocity &vel)
{
  char pl[10];
  char pa[10];

  ROS_INFO("linear: [%f] angular: [%f].",vel.linear,vel.angular);	
  ROS_INFO("linear: [%s] angular: [%s].",gcvt(vel.linear,6,pl),gcvt(vel.angular,6,pa));

  packSend(fd_,'v',pl);//send the value of the velocity
  packSend(fd_,'w',pa);//send the value of the angular velocity
}
void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out){
	// Pairs of coords with units will be used so often build a function build a dedicated function for returning such
	
	char temp[20];
	if (units != NULL) scaling = 1;  // If units have been defined then ignore the scaling parameter
	strcat(out, gcvt(scaling*ent->ret_x(),precision,temp) );  // There must be a better function for double to ascii conversion that is defined in most libraries
	if (units != NULL) strcat(out, units);
	strcat(out, delim);
	strcat(out, gcvt(-scaling*ent->ret_y(),precision,temp) ); // Because SVG has a the Y-axis pointed down multiply by -1
	if (units != NULL) strcat(out, units);
	strcat(out, " ");
}
Example #11
0
int main()
{
	clock_t t1, t2, t3, t4, t5, t6;
	char a[50], b[50], c[50];

	printf("Hi, v1.7\n");
	printf("Running algorithm for task: ");
	printf((task)?"4+\n":"1-3\n");
	printf("Dividing result by 1024 is: ");
	printf((div_1024)?"ON\n":"OFF\n");
	////////////////
	//test case 1 //
	////////////////
	printf("gen vector 1, ");
	generateVector(x1, N1, S1);
	printf("sum vector 1\n");
	float y1=0.0;
	if (task) {t1 = times(NULL); y1 = sumVector_cos_custom(x1, N1); t2 = times(NULL);}
	else {t1 = times(NULL); y1 = sumVector(x1, N1); t2 = times(NULL);}
	gcvt(t2-t1, 10, a);
	alt_putstr("Time = "); alt_putstr(a); alt_putstr("; ");
	printf("Result = %f\n", ((div_1024)?y1/1024:y1));

	////////////////
	//test case 2 //
	////////////////
	printf("gen vector 2, ");
	generateVector(x2, N2, S2);
	printf("sum vector 2\n");
	float y2=0.0;
	if (task) {t3 = times(NULL); y2 = sumVector_cos_custom(x2, N2); t4 = times(NULL);}
	else {t3 = times(NULL); y2 = sumVector(x2, N2); t4 = times(NULL);}
	gcvt(t4-t3, 10, b);
	alt_putstr("Time = "); alt_putstr(b); alt_putstr("; ");
	printf("Result = %f\n", ((div_1024)?y2/1024:y2));

	////////////////
	//test case 3 //
	////////////////
	printf("gen vector 3, ");
	generateVector(x3, N3, S3);
	printf("sum vector 3\n");
	float y3=0.0;
	if (task) {t5 = times(NULL); y3 = sumVector_cos_custom(x3, N3); t6 = times(NULL);}
	else {t5 = times(NULL); y3 = sumVector(x3, N3); t6 = times(NULL);}
	gcvt(t6-t5, 10, c);
	alt_putstr("Time = "); alt_putstr(c); alt_putstr("; ");
	printf("Result = %f\n", ((div_1024)?y3/1024:y3));


	return 0;
}
Example #12
0
int main()
{
	//将浮点型数转换成字符串取四舍五入
										//范例有错误
	double a = 123.45;
	double b = -1234.56;
	char *ptr;
	int decpt,sign;
	gcvt(a,5,ptr);
	printf("a value=%s\n",ptr);
	ptr=gcvt(b,6,ptr);
	printf("b value=%s\n",ptr);
}
Example #13
0
int FAR PASCAL
DialogVector2D(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 
 char *strbuffer;
 Vector2D *vtemp;
 
 switch (message)
	{
		case WM_INITDIALOG:
			strbuffer=new char[20];
			vtemp=(Vector2D *)(CT_data);
			strbuffer=gcvt((double)(vtemp->x),3,strbuffer);
            SetDlgItemText(hWnd,IDC_EDIT1,strbuffer);
			strbuffer=gcvt((double)(vtemp->y),3,strbuffer);
            SetDlgItemText(hWnd,IDC_EDIT2,strbuffer);

			SetDlgItemInt(hWnd,IDC_STATICN,CT_keynum,false);
			SetDlgItemInt(hWnd,IDC_STATICM,CT_keypos,false);
			delete [] strbuffer;

			SetFocus(GetDlgItem(hWnd,IDC_EDIT1));
			PostMessage(GetDlgItem(hWnd,IDC_EDIT1),EM_SETSEL,0,10);

			return FALSE;

		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK) 
			{
				strbuffer=new char[20];
				GetDlgItemText(hWnd,IDC_EDIT1,strbuffer,20);
				vtemp=(Vector2D *)CT_data;
				vtemp->x=(float)atof(strbuffer);
				GetDlgItemText(hWnd,IDC_EDIT2,strbuffer,20);
				vtemp->y=(float)atof(strbuffer);
				delete [] strbuffer;
				EndDialog(hWnd, LOWORD(wParam));
				return TRUE;
			}
			if (LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hWnd, LOWORD(wParam));
				return TRUE;
			}
			break;
	}
    return FALSE;
}
bool use_gcvt(double number, char* string, short size)
{
	char *buffer,*temp ;
	int length;

	temp = gcvt (number, size, string);
	length = strlen(temp);
	buffer = (char *) malloc (length + 2);
	if (buffer==NULL)
		return false;

	strcpy(buffer,temp);
	if (temp[length-1] == '.')
	{
		strcpy(buffer,temp);
		strcat(buffer,"0");
	}
	if (temp[0] == '.')
	{
		strcpy( buffer, "0");
		strcat( buffer, temp);
	}
	strcpy(string,buffer);
	free (buffer);

	if (strlen(string)>size)
		return false;
	else
		return true;
}
Example #15
0
// 鼠标移动事件(点击鼠标任何键)的处理函数
gboolean motion_event_callback(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
	// 获得移动鼠标的坐标值
	gint x = event->x;
	gint seek_sec = 0;
	char cmd[32] = "seek ";
	char buf[8] = {0};
	MPLAYER *pm = (MPLAYER*)data;

	if(pm->playflag == playing) pm->playflag = stop;

	seek_sec = x * song.end_time/400;          //毫秒
	seek_sec = (seek_sec - song.cur_time)/1000;//秒
	
	printf("seek_sec = %d\n",seek_sec);
	
	gcvt(seek_sec,5,buf);
	strcat(cmd, buf);
	strcat(cmd,"\n");
	printf("cmd = %s\n",cmd);
	send_cmd(cmd,pm);

	pm->playflag == playing;
	//gint j = event->y;
	//printf("motion_x = %d, motion_y = %d\n", i, j);
	return TRUE;
}
Example #16
0
unsigned long BoxRoundBottomDistantProcedure(HWND Window,HMSG Message,long Param1,long Param2)
{
  switch (Message)
  {
    case WINDOWINIT:
         {
           char MidString[20];

           gcvt(ConvertToSystemMeter((float)TmpTextBox.RoundDistantBottom/(float)(SCALEMETER)),
                5,MidString);
           MessageGo(Window,SETLINEBUFFER,FP2LONG(MidString),0l);
           break;
         }
    case DIALOGBOXOK:
         {
           long MidBuffer;
           char *MidString;

           MidBuffer=MessageGo(Window,GETLINEBUFFER,0l,0l);
           MidString=(char *)LONG2FP(MidBuffer);
           if (IsInvalidDigit(MidString))
           {
              MessageBox(GetTitleString(ERRORINFORM),
                         GetInformString(INVALIDBOXROUNDBOTTOMDISTANT),1,
                         WindowGetFather(Window));
              return(FALSE);
           }
           TmpTextBox.RoundDistantBottom=ConvertToUserMeter((float)SCALEMETER*atof(MidString))+0.5;
           break;
         }
    default:
         return(SingleLineEditorDefaultProcedure(Window,Message,Param1,Param2));
  }
  return(TRUE);
}
Example #17
0
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;
}
Example #18
0
int main()
{
	char a[50];
clock_t t1,t2;
float x[255001]={0};
int i=0;
int n=4*255001;
float result1=0;
float result2=0;
float result3=0;
float result4=0;
float result5=0;
float result6=0;
	for (i=0;i<255001;i++){
		x[i]=i*0.001;
	}
	printf("hello world\n");
	t1 = times(NULL);
	result1=ALT_CI_SUM_VECTOR_0((int)x,n);
	t2 = times(NULL);
	result2=ALT_CI_SUM_VECTOR_0((int)x,n);
	result3=ALT_CI_SUM_VECTOR_0((int)x,n);
	result4=ALT_CI_SUM_VECTOR_0((int)x,n);
	result5=ALT_CI_SUM_VECTOR_0((int)x,n);
	result6=ALT_CI_SUM_VECTOR_0((int)x,n);
	printf("%f\n",result1);
	printf("%f\n",result2);
	printf("%f\n",result3);
	printf("%f\n",result4);
	printf("%f\n",result5);
	gcvt(t2-t1, 10, a);
	alt_putstr("Time = "); alt_putstr(a); alt_putstr("; ");
  return 0;
}
Example #19
0
unsigned long ImageShadowProcedure(HWND Window,HMSG Message,long Param1,long Param2)
{
  switch (Message)
  {
    case WINDOWINIT:
         {
           char MidString[20];
           int AttributePosition;

           gcvt(TmpAttribute4,6,MidString);
           MessageGo(Window,SETLINEBUFFER,FP2LONG(MidString),0l);
           break;
         }
    case DIALOGBOXOK:
         {
           long MidBuffer;
           char *MidString;

           MidBuffer=MessageGo(Window,GETLINEBUFFER,0l,0l);
           MidString=LONG2FP(MidBuffer);
           TmpAttribute4=atof(MidString);
           if (TmpAttribute4<0||TmpAttribute4>=MAXCHARCOLOR)
           {
              MessageBox(GetTitleString(ERRORINFORM),
                         GetInformString(INVALIDCHARCOLOR),1,
                         WindowGetFather(Window));
              return(FALSE);
           }
           break;
         }
    default:
         return(SingleLineEditorDefaultProcedure(Window,Message,Param1,Param2));
  }
  return(TRUE);
}
Example #20
0
void CCalcUnary::OnDeterminant() 
{
	// TODO: Add your control notification handler code here
        // TODO: Add your control notification handler code here
        UpdateData();
        xpMatrix  mtx;
        CWaitCursor wait;
		float ret = 0;
        //invert the matrix
        try
        {
           //CAllPages * pParent = STATIC_DOWNCAST(CAllPages, GetParent());
		   char buffer[255];
           if (getMatrix(mtx) == TRUE)
           {
              wait.Restore( );
			  m_det = gcvt(mtx.getDet(),10, buffer);
              //m_det = _gcvt(mtx.getDet());
           }
		   UpdateData(false);	
           //pParent->m_pMtx = &m_mtxResult;
           //pParent->SetActivePage(0);
           //pParent->m_calcResults.pGridCtrl->Refresh();
        }
        catch (xpException * e)
        {
           CString errMess;
           e->getErrorMessage(errMess);
           MessageBox(errMess, "Matrix Calculation Error", MB_OK);
           e->Delete();
        }
	
}
Example #21
0
bool dx_NombreGDI (float pNombre, uint8 pDecimales,
                   uint16 pPosX, uint16 pPosY, COLORREF pCouleur)
{
    // this function draws the sent text on the sent surface
    // using color index as the color in the palette

    HDC xdc; // the working dc

    // get the dc from surface
    if (FAILED (SurfaceBack->GetDC (&xdc))) return false;

    char pTexte[128];

    gcvt ((double)pNombre, pDecimales, pTexte);

    WCHAR Texte[128] = {0};
    MultiByteToWideChar (GetACP(), 0, pTexte, -1, Texte, 128);


    SetTextColor (xdc, pCouleur);       // set the colors for the text
    SetBkMode    (xdc, TRANSPARENT); // set background mode to transparent so black isn't copied
    TextOut      (xdc, pPosX, pPosY, Texte, strlen (pTexte)); // draw the text

    SurfaceBack->ReleaseDC (xdc); // release the dc

    return true;
}
Example #22
0
int main()
{
	start_notch(
			_binary_beeth5_noise_bin_start,
			_binary_beeth5_noise_bin_end,
			_alt_partition_beethout_start
			);

	//The notch filtering will be conducted in the background.
	//Code to perform other useful tasks can be put here.
	while(notch_busy());

	//Read performance counter
	unsigned int performance = notch_performance();

	//Print time taken for filtering operation
	char buf[16];
	gcvt((float)performance/ALT_CPU_FREQ, 10, buf);
	alt_putstr(" proc time = "); alt_putstr(buf); alt_putstr(" seconds \n");

	//start_notch(
	//		_binary_beeth5_noise_bin_start,
	//		_binary_beeth5_noise_bin_end,
	//		PWM_0_BASE
	//		);

	while(1);
}
Example #23
0
char* pValue::toStr()
{
    int i1, i2;
    char *tval = new char[16];
    switch(type) {
	case SHORTINT:
	    return fcvt(*(short*)data, 0, &i1, &i2);
	    break;
	case INTEGER:
	    return fcvt(*(int*)data, 0, &i1, &i2);
	    break;
	case DOUBLE:
	    gcvt(*(double*)data, 8, tval);
	    return tval;
	    break;
	case STRING:
	    return data;
	    break;
	default:
	    //BUG
	    
	    return NULL;
    };
    
}
Example #24
0
int plugin_settings_setfloat(const char *splg, const char *sname, double sval)
{
	char tbuffer[512];

	gcvt(sval, 256, tbuffer);
	return plugin_settings_set(splg, sname, tbuffer);
}
Example #25
0
string dblToStr(const double& nt)
{
    char str[25];
    int sig = 5; /* significant digits */
    char* ptr =  gcvt(nt, sig, str);
    return string(str);
}
Example #26
0
void Font_bitmap::Print_vec(int x, int y, const vec &a, char *meno)
{
	if(meno!=NULL)
	{
		Print(x, y, meno,0);
		x += strlen(meno)+1;
	}
	
	gcvt( (double)a.x, 2, text);
	Print(x,y,text,0);
	x+=10;
	gcvt( (double)a.y, 2, text);
	Print(x,y,text,0);
	x+=10;
	gcvt( (double)a.z, 2, text);
	Print(x,y,text,0);
}
Example #27
0
// char *gcvt(double number, size_t ndigits, char *buf);
int main() {
    char ptr[20];
    double a = 100;
    gcvt(a, 10, ptr);
    int length = strlen(ptr);
    printf("%s length = %d\n", ptr, length);
    return 0;
}
Example #28
0
String::String( const double& val_ ) {

    int          run1      ;
    char        *char_value;
    char        *tmp       ;
    char        *dummy     ;
    BooleanType  dot       ;

    const int precision = 16;

    dot = BT_FALSE;

    char_value = (char*)malloc(MAX_LENGTH_STRING*sizeof(char));
    tmp        = (char*)malloc(MAX_LENGTH_STRING*sizeof(char));

    dummy = gcvt( val_ , precision , char_value );

    length = 0;
    run1 = 0;

    while( char_value[run1] == '1' || char_value[run1] == '0' ||
            char_value[run1] == '3' || char_value[run1] == '2' ||
            char_value[run1] == '5' || char_value[run1] == '4' ||
            char_value[run1] == '7' || char_value[run1] == '6' ||
            char_value[run1] == '9' || char_value[run1] == '8' ||
            char_value[run1] == '.' || char_value[run1] == 'e' ||
            char_value[run1] == 'n' || char_value[run1] == 'a' ||
            char_value[run1] == 'i' || char_value[run1] == 'n' ||
            char_value[run1] == 'f' || char_value[run1] == ' ' ||
            char_value[run1] == '+' || char_value[run1] == '-' ) {

        if( dot == BT_FALSE && char_value[run1] == 'e' ) {
            tmp[length] = '.';
            length++;
            dot = BT_TRUE;
        }
        tmp[length] = char_value[run1];
        length++;
        if( char_value[run1] == '.' ) dot = BT_TRUE;
        run1++;
    }
    free(char_value);

    if( dot == BT_FALSE ) {
        tmp[length] = '.';
        length++;
    }

    tmp[length] = '\0';
    length++;

    name = new char[length];
    for( run1 = 0; run1 < (int) length; run1++ )
        name[run1] = tmp[run1];

    free(tmp);
}
Example #29
0
void SerialCom::velSend(const dlut_move_base::Twist &tw)
{
  char pl[10];
  char pa[10];	

  double vel_linear,vel_angular;
  vel_linear = tw.linear.x;
  vel_angular = tw.angular.z;

  ROS_INFO("linear: [%f] angular: [%f].",vel_linear,vel_angular);

  ROS_INFO("linear: [%s].",gcvt(vel_linear,6,pl));
  ROS_INFO("angular: [%s].",gcvt(vel_angular,6,pa));

  packSend(fd_,'v',pl);//send the value of the velocity
  packSend(fd_,'w',pa);//send the value of the angular velocity
  ROS_INFO("velSend function called!");
}
double CScript::ViewPlayerAllVariableList(const char* cmd, char* retStr)
{
	CPlayer* pPlayer=dynamic_cast<CPlayer*>(p_SrcShape);
	if(pPlayer)
	{
		char szVarInfo[5120];
		_snprintf(szVarInfo, 5120, "All Normal Var Num: %d", pPlayer->GetVariableList()->GetVarNum());
		pPlayer->SendNotifyMessage(szVarInfo, 0xFFFFFFFF, 0x0, eNOTIFYPOS_LEFT_BOTTOM);

		CVariableList::VarList* pVarList = pPlayer->GetVariableList()->GetVarList();
		if(pVarList)
		{
			CVariableList::varlistitr varItr = pVarList->begin();
			for(; varItr != pVarList->end(); varItr++)
			{
				if(varItr->second->Array < 0)
					_snprintf(szVarInfo, 5120, "%s : %s", varItr->first.c_str(), varItr->second->strValue);
				else if(varItr->second->Array == 0)
				{
					_snprintf(szVarInfo, 5120, "%s : %f", varItr->first.c_str(), *((double*)varItr->second->strValue));
				}
				else if(varItr->second->Array > 0)
				{
					_snprintf(szVarInfo, 5120, "%s : ", varItr->first.c_str());

					char szArray[1024];
					for(int i=0; i<varItr->second->Array; i++)
					{
						gcvt(varItr->second->Value[i], 10, szArray);
						strcat(szVarInfo, szArray);
						strcat(szVarInfo, ";");
					}
				}
				pPlayer->SendNotifyMessage(szVarInfo, 0xFFFFFFFF, 0x0, eNOTIFYPOS_LEFT_BOTTOM);
			}
		}

		_snprintf(szVarInfo, 5120, "All GUID Var Num: %d", pPlayer->GetVariableList()->GetGuidNum());
		pPlayer->SendNotifyMessage(szVarInfo, 0xFFFFFFFF, 0x0, eNOTIFYPOS_LEFT_BOTTOM);

		CVariableList::GuidList* pGuidList = pPlayer->GetVariableList()->GetGuidList();
		if(pGuidList)
		{
			CVariableList::GuidList::iterator guidItr = pGuidList->begin();
			for(; guidItr != pGuidList->end(); guidItr++)
			{
				char szGuid[128];
				guidItr->second->tostring(szGuid);
				_snprintf(szVarInfo, 128, "%s : %s", guidItr->first.c_str(), szGuid);
				pPlayer->SendNotifyMessage(szVarInfo, 0xFFFFFFFF, 0x0, eNOTIFYPOS_LEFT_BOTTOM);
			}
		}
	}

	return 0.0f;
}