Sign in

username:

password:



Not a member?

Search c55x



Search tips

Subscribe to c55x



c55x by Keywords

AIC23 | C5509 | CCS | CSL | EMIF | EVM | GEL | GPIO | HPI | Interfacing | JTAG | McBSP | OMAP | Omap15 | OMAP59 | RTDX | SDRAM | TMS320VC5509 | USB | XDS5


Discussion Groups

Discussion Groups | TMS320C55x | getting value in decimal point

Technical discussions about the TI C55x DSPs (including the c5501, c5502, c5503, c5507, c5509, c5510 and OMAP5910).

  

Post a new Thread

getting value in decimal point - henry low - Mar 1 16:56:13 2007



Hi,

I am writing a code to sort the maximum value from an array. i had
tried and it works but the problem arise when the value is in decimal
point. it cant recognize the decimal value. for instance if the value
in the array is 222.22 after run the program using watch window to
view the sine1_max variable i can only see 222.0? can anyone help me
on this. this is part of my code
DATA sinetable1[SINE_TABLE_SIZE] = {
    0,  1,   2,   3,   4,   5,   6,  7,
    8,  9,  222.22,  11,  1,  11,  10,  9,};

int sine1_max, sine2_max;

int main()
{
sine1_max= compare(sinetable1,SINE_TABLE_SIZE,&phase_count1);  
//function call
sine2_max= compare(sinetable2,SINE_TABLE_SIZE,&phase_count2);  
//function call
return 0;
}

int compare(int sine[], int size, int *phase)
{
	int x;
	int temp;
	temp=sine[0];
		
	for (x=1; x < size; x++)
	{
		if (sine[x]>temp)
		{ 
			temp=sine[x];
			*phase=x;
		}
	}

	return temp;
}

best regards,
han wee



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

RE: getting value in decimal point - Lance Ralph - Mar 1 17:16:40 2007

If you want to have decimal values, use a float.  sine1_max is an int.

________________________________

From: c...@yahoogroups.com [mailto:c...@yahoogroups.com] On Behalf Of
henry low
Sent: Thursday, March 01, 2007 5:00 PM
To: c...@yahoogroups.com
Subject: [c55x] getting value in decimal point

Hi,

I am writing a code to sort the maximum value from an array. i had
tried and it works but the problem arise when the value is in decimal
point. it cant recognize the decimal value. for instance if the value
in the array is 222.22 after run the program using watch window to
view the sine1_max variable i can only see 222.0? can anyone help me
on this. this is part of my code

DATA sinetable1[SINE_TABLE_SIZE] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 222.22, 11, 1, 11, 10, 9,};

int sine1_max, sine2_max;

int main()
{
sine1_max= compare(sinetable1,SINE_TABLE_SIZE,&phase_count1); 
//function call
sine2_max= compare(sinetable2,SINE_TABLE_SIZE,&phase_count2); 
//function call
return 0;
}

int compare(int sine[], int size, int *phase)
{
int x;
int temp;
temp=sine[0];

for (x=1; x < size; x++)
{
if (sine[x]>temp)
{ 
temp=sine[x];
*phase=x;
}
}

return temp;
}

best regards,
han wee



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

RE: getting value in decimal point - Lance Ralph - Mar 5 9:30:42 2007

Do you have a prototype defined? 

Please reply to the group so that others more knowledgeable than myself
may be of assistance.

-----Original Message-----

From: n...@yahoogroups.com [mailto:n...@yahoogroups.com
<mailto:n...@yahoogroups.com> ] On Behalf Of henry low

Sent: Monday, March 05, 2007 9:01 AM

Subject: getting value in decimal point

Hi,

I had made changes to the code by declaring the variable into float but
i am facing problem with error which stated

line98: error: declaration is incompatible with previous "compare" 

(declared at line 75) 

These are the changes i had made to the code

float sinetable1[SINE_TABLE_SIZE] = {

0, 1, 2, 3, 4, 5, 6, 7,

8, 9, 222.22, 11, 1, 11, 10, 9,};

float sine1_max, sine2_max;

int phase_count1=0, phase_count2=0;

int main()

{ sine1_max= compare(sinetable1,SINE_TABLE_SIZE,&phase_count1);

[line 75] 

//function call

sine2_max= compare(sinetable2,SINE_TABLE_SIZE,&phase_count2); 

//function call

float compare(float sine[], int size, int *phase) [line 98]

{ int x;

float temp;

temp=sine[0];

for (x=1; x < size; x++)

{

if (sine[x]>temp)

{ 

temp=sine[x];

*phase=x;

}

}

return temp;

}

thanks for your help.

best regards,

Han Wee

________________________________

From: c...@yahoogroups.com [mailto:c...@yahoogroups.com] On Behalf Of
Lance Ralph
Sent: Thursday, March 01, 2007 5:31 PM
To: henry low; c...@yahoogroups.com
Subject: RE: [c55x] getting value in decimal point

If you want to have decimal values, use a float.  sine1_max is an int.

________________________________

From: c...@yahoogroups.com [mailto:c...@yahoogroups.com] On Behalf Of
henry low
Sent: Thursday, March 01, 2007 5:00 PM
To: c...@yahoogroups.com
Subject: [c55x] getting value in decimal point

Hi,

I am writing a code to sort the maximum value from an array. i had
tried and it works but the problem arise when the value is in decimal
point. it cant recognize the decimal value. for instance if the value
in the array is 222.22 after run the program using watch window to
view the sine1_max variable i can only see 222.0? can anyone help me
on this. this is part of my code

DATA sinetable1[SINE_TABLE_SIZE] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 222.22, 11, 1, 11, 10, 9,};

int sine1_max, sine2_max;

int main()
{
sine1_max= compare(sinetable1,SINE_TABLE_SIZE,&phase_count1); 
//function call
sine2_max= compare(sinetable2,SINE_TABLE_SIZE,&phase_count2); 
//function call
return 0;
}

int compare(int sine[], int size, int *phase)
{
int x;
int temp;
temp=sine[0];

for (x=1; x < size; x++)
{
if (sine[x]>temp)
{ 
temp=sine[x];
*phase=x;
}
}

return temp;
}

best regards,
han wee



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )