NXC: float / int bug
Posted: 11 Dec 2013, 18:39
weird:
by this program it calcuates correctly 0:
and by this strangely 24 !!!
by this program it calcuates correctly 0:
Code: Select all
task main() {
int R[3][3]; int det;
R[0][0]=111; R[0][1]=444; R[0][2]=777;
R[1][0]=222; R[1][1]=555; R[1][2]=888;
R[2][0]=333; R[2][1]=666; R[2][2]=999;
det= R[0][0]*R[1][1]*R[2][2]
+R[0][1]*R[1][2]*R[2][0]
+R[0][2]*R[1][0]*R[2][1]
-R[0][2]*R[1][1]*R[2][0]
-R[0][1]*R[1][0]*R[2][2]
-R[0][0]*R[1][2]*R[2][1] ;
NumOut(0,0, det);
while(1);
}
and by this strangely 24 !!!
Code: Select all
task main() {
float R[3][3]; float det;
R[0][0]=111; R[0][1]=444; R[0][2]=777;
R[1][0]=222; R[1][1]=555; R[1][2]=888;
R[2][0]=333; R[2][1]=666; R[2][2]=999;
det= R[0][0]*R[1][1]*R[2][2]
+R[0][1]*R[1][2]*R[2][0]
+R[0][2]*R[1][0]*R[2][1]
-R[0][2]*R[1][1]*R[2][0]
-R[0][1]*R[1][0]*R[2][2]
-R[0][0]*R[1][2]*R[2][1] ;
NumOut(0,0, det);
while(1);
}