I
I
ikerya2017-06-10 17:16:51
Delphi
ikerya, 2017-06-10 17:16:51

Why does Delphi operate incorrectly on real?

Why, when raising a number to a power, for some reason (and somehow) it is multiplied by 0.1 and the result is not what it should be? Let's say I raise four to the third power, it should turn out 4 * 4 * 4 = 64, but it turns out 6.400000000. Why is that?

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a, b, c, d: real;

begin
  writeln('input a, b, c and d:');
  readln(a, b, c, d);

  if (((b > a) AND (c > b) AND (d > c)) OR ((a > b) AND (b > c) AND (c > d))) then
    begin
      a := exp(3 * ln(a));
      b := exp(3 * ln(b));
      c := exp(3 * ln(c));
      d := exp(3 * ln(d));
    end
  else
    begin
      a := 3;
      b := 3;
      c := 3;
      d := 3;
    end;

  writeln('a = ', a, ' b = ', b, ' c = ', c, ' d = ', d);

  readln;
end.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2017-06-10
@immaculate

https://habrahabr.ru/post/112953/

K
kalapanga, 2017-06-10
@kalapanga

Yes, well, what for, an error is an error, but not ten times. You somewhere on the output of the number did not notice the degree. there should be something like 6.40000+01. If not, then give a screenshot with the input and output of this program. I want to see this miracle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question