Hello,
I have this code and I noticed a strange problem:
void test(float a,float b)
{
Uint32 c = (a/b)-1;
if(c) asm(" ESTOP0");
// here c = 199998 ?????
}
void main()
{
test(200E6,1E3);
}
c is equal to 199998 instead of 199999 why ??
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I have this code and I noticed a strange problem:
void test(float a,float b)
{
Uint32 c = (a/b)-1;
if(c) asm(" ESTOP0");
// here c = 199998 ?????
}
void main()
{
test(200E6,1E3);
}
c is equal to 199998 instead of 199999 why ??
Hi Mauro,
Which controller are you using for this computation?
Also, if you check this link, where Vishal clearly mentions that :
The result is 178 which you will have to divide by 100 - which WILL NOT GIVE YOU 1.78 BUT 1.779999....200E6/1E3 would give you 199999 and not 200000! Hence you get the result as 199998.
Do refer: http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/359773.aspx
Regards,
Gautam