PascalABC.NET does not consider the logarithm of the

In the lab you need to calculate the logarithm.
I use the function from the base library Ln.
As argument pass 1( in a variable).
Outputs: -1.11022302462516 E-16.

What to do?
October 3rd 19 at 01:25
3 answers
October 3rd 19 at 01:27
Solution
Most likely he just gave you approximate value and must be rounded, because in a variable you have not stored the 1.
Again check that you have stored in a variable, if does not help, throw off the code of the program I look.
For example, the following code outputs 0
var i: double;
begin
i:=1;
 writeln(Ln(i)); 
end.
Rounded - seems to work. But I'm very impressed) - Tavares_Swift85 commented on October 3rd 19 at 01:30
October 3rd 19 at 01:29
All finally sorted out!

There is a small error in the calculation of the tangent:
( so the value of Pi is constant and equal to the standard library PABCSystem Pi = 3.141592653589793)
n1 + n2 = 0.785398163397448;
tan(n1 + n2)=1.0000...
9849602_bigthumb.jpg 9849637_bigthumb.jpg
Probably that is why the result of calculating values of the logarithm, we get the approximate value 0,0000000000000001...
I think that this error is quite normal...

PS
Immediately respond to your comment: "I understand the bad code, but it just Laba))" suggest from in the labs to download skill for writing good code, although the code is not particularly bad.
Thank you for your attention and success in school!
I will try! Thanks again! - Tavares_Swift85 commented on October 3rd 19 at 01:32
October 3rd 19 at 01:31
///Returns the integral
function Integral(var x: integer; n: integer): real;
var
 tng, temp: real;
 n1, n2: real;
begin
 if n = 1 then
begin
 n1 := (Pi / 4);
 n2 := (x / 2);
 tng := tan(n1 + n2);
 temp := ln(tng);
 integral := temp;
 //the compiler incorrectly considers the logarithm!!!
end;
 if n = 0 then

 integral := x;
 if n >= 2 then
 integral := ((1 / n - 1) * (sin(x)) / power(cos(x), n - 1)) + (((n - 2) / (n - 1)) * integral(x, n - 2))
else


end;

//To deal with reference to the parameters

var
 x: integer;
 n: integer;

begin
writeln('read(x)');
read(x);
writeln('phony(n)');
phony(n);

 //writeln('Integral of dx/(cos', x, ')^', n, '=', integral(x, n));
end.


There task is simple. Integral to calculate. It seems that when n=1, then it must issue a logarithm, and as for the test I chose the values x=0 n=1, then the program should return 0, but....alas.
understand bad code, but it's just the lab)) - Tavares_Swift85 commented on October 3rd 19 at 01:34

Find more questions by tags Pascal