N
N
Nik_Haker2015-05-21 19:01:19
Programming
Nik_Haker, 2015-05-21 19:01:19

Why is C++ result rounded?

a=Edit1->Text;
b=Edit2->Text;
double m=StrToInt(a);
double n=StrToInt(b);
double o=StrToInt(Edit4->Text);
double sina=sin(o*PI/180);
double sinb=n/(m/sina);
B=asin(sinb);
B=B*180/PI;
Edit5->Text = B;
tested with values ​​a=5 b=6 A=30. the result is 38, although it actually turns out to be 36.8698976458 why is it rounded off?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Silin, 2015-05-21
@Nik_Haker

Perhaps you have somewhere where int is used during calculations, look at it more carefully. What type B?

@
@coodan, 2015-05-31
_

I guessed on the cards - it did not help. Threw bones - too. I asked the stars for an answer. The stars are interested - is it because you divide by 180? :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question