Re: Finding antilogarithm with Delphi
Posted by webmaster Guido
In Reply to: Finding the antilogarithm with Delphi posted by Lionel Joyner:
: 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";
For my test, I used a form with two buttons and two editboxes:
// 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;
Does this clarify your problem? Please ask again if I understood you wrongly.