1. /* sdflnxmd.cpp by K.Tsuru */
  2. // function ID 3408 DRADIX since ver. 2.30
  3. /*--------------------------------------------------------------------------
  4. Get a calculation method for log(x) functions.
  5. x = X * 10^exp
  6. log(x) = log(X)+exp*log(10), add = exp*log(10)
  7. It returns true if x = 1 or 10, set X = 0 or log(10).
  8. ----------------------------------------------------------------------------*/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. static const SDouble TEN(10.0);
  13. static const char* const func = "Log(x)";
  14. bool GetLogxCalcMethod(const SDouble& x, SDouble& X, SDouble& add){ //3406
  15. if(x.Sign(3408) <= 0) x.SetError(x.DOMAIN_ERR, func, 3408); // x <= 0
  16. if(x.IsOne()) {
  17. X.SetZero(); return true; // x = 1.0
  18. }
  19. if(x == TEN) {
  20. X = Log10(); return true; // x = 10
  21. }
  22. // Convert into x = X * 10^exp where 0< X < 1.0
  23. long exp; // exponent
  24. X = SDtoE_Form(x, &exp);
  25. // log(x) = log(X)+exp*log(10), add = exp*log(10)
  26. if(exp != 0) add = exp * Log10(); // It must pass through this statement for x = 10.
  27. else add.SetZero();
  28. return false;
  29. }

sdflnxmd.cpp : last modifiled at 2016/04/04 10:38:56(1,073 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).