I have this line in the knowledge base:
height(Hipot,Y) :- Y is sin(pi/6)*Hipot.
which calculates one of the cathetus of a right triangle.
When asking Prolog for the value of Y
, that is the cathetus, I get an inaccurate number:
?- height(1,Y).
Y = 0.49999999999999994.
But the real value is 1/2, so it should output 0.5. I guess that the inaccuracy is because of the use of pi
, but I want to keep using it so how can I round Y
to 0.5?