#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# why result from calculator as not equal as from program?

edited March 2016

Hi, I confuse about the result from calculator not equal from promgram. How about round float number in processing.

Calculate with MS excel

Calculate with Procesing

Below is my code.

``````float A,B,C;

void setup(){
size(300,300);
A=-7;
B=6;
C=-5;
float r = sqrt(sq(A)+sq(B)+sq(C));
float t = degrees(atan(sqrt((sq(A)+sq(B)))/C));
float p = degrees(atan(B/A));
println(r,t,p);

}
``````
Tagged:

• edited March 2016

Use datatype `double` + class Math:

``````final int A = -7, B = 6, C = -5;

float r = sqrt( A*A + B*B + C*C );
float t = degrees(atan( sqrt(A*A + B*B) / C ));
float p = degrees(atan( (float) B/A ));

println(r, t, p); // 10.488089 -61.527863 -40.60129
exit();
``````

``````final int A = -7, B = 6, C = -5;

double r = Math.sqrt( A*A + B*B + C*C );
double t = Math.toDegrees(Math.atan( Math.sqrt(A*A + B*B) / C ));
double p = Math.toDegrees(Math.atan( (double) B/A ));

println(r, t, p); // 10.488088481701515 -61.527865575427 -40.60129464500447
exit();
``````

• This has been answered before ;)