Other Parts Discussed in Thread: TEST2
Tool/software: TI C/C++ Compiler
Hi,
i have found a problem on math operations using:
TMS320F28235
TI v18.1.6.LTS compiler (optimization 4/5)
CCS v7.3.0.00019
Let me provide an example code:
long Test1;
int Test2;
......// variable initialization
Test2=15;
Test1 = (Test2*10)/3; // Test1=5 !!!!!!! ERROR!!!
I have test alternative code as:
Test1 = (Test2*100)/30; // Test1=5 !!!!!!! ERROR!!!
Test1 = (Test2*101)/30; // Test1=50 !!!!!!! CORRECT
Test1 = (Test2*10L)/3; // Test1=50 !!!!!!! CORRECT forcing the secon operation to LONG it seems to work correctly.
Test1 = ((Long)Test2*10)/3; // Test1=50 !!!!!!! CORRECT forcing the first operation to LONG it seems to work correctly.
if I split the opration in two step:
Test1 = (Test2*10);
Test1 = Test1/3; // Test1=50 !!!!!!! CORRECT
so I'm not so sure to have understood the math operation issue.
other test .. defining
long Test1;
unsigned int Test2;
.... ......// variable initialization
Test2=15;
Test1 = (Test2*10)/3; // Test1=50 !!!!!!! CORRECT!!!
so what's change beetween the two cases? Test2 defined int or unsigned int..
Please give me support!!
Best Regards
Massimo