Re: Finding the antilogarithm

Posted by Lionel on February 20, 2004 at 11:16:27:

In Reply to: Re: Finding the antilogarithm posted by webmaster Guido on February 19, 2004 at 21:54:10:

: : The problem is that when I use the (Log10(X)) the results is the mantissa and when I inverse using (Power(10,X)) I get the mantissa.

: : How does one handle the +/- characteristic in this perplexing situation so they get the real number?
: ------------------------------------

: I don't quite understand what you mean, that's not what I get with my testcode:

: - the result of Log10(X) gives the logarithm in base 10 of X, not only the "mantissa";
: example: Log10(5000) gives 3,69897000433602
:
: - when I use Power(10, X) I get 10 to the power X, not the "mantissa";
: example: Power(10, 3) gives 1000

: For my test, I used a form with two buttons and two editboxes:
: - an Edit for what you called the "real number", named edNumber;
: - and another Edit for the logarithm, named edLog.

: // Calculate the logarithm with base 10 of a number X that
: // was entered in edNumber and display result L in edLog
: procedure TForm1.btnCalcLogClick(Sender: TObject);
: var
: L, X: real;
: ErrCode: integer;
: begin
: Val(edNumber.Text, X, ErrCode); // input number
: L := Log10(X); // calculate logarithm
: edLog.Text := FloatToStr(L);
: end;

: // Calculate the antilogarithm with base 10 of a number L that
: // was entered in edLog and display result X in edNumber
: procedure TForm1.btnCalcAntiLogClick(Sender: TObject);
: var
: L, X: real;
: ErrCode: integer;
: begin
: Val(edLog.Text, L, ErrCode); // input logarithm
: X := Power(10, L); // calculate antilogarithm
: edNumber.Text := FloatToStr(X);
: end;